-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
VTAdmin to use VTGate's vexplain #17508
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: c-r-dev <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17508 +/- ##
==========================================
- Coverage 67.64% 67.62% -0.02%
==========================================
Files 1586 1587 +1
Lines 255629 255758 +129
==========================================
+ Hits 172910 172958 +48
- Misses 82719 82800 +81 ☔ View full report in Codecov by Sentry. |
Signed-off-by: c-r-dev <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please have a look at the comments, rest looks good to me. Would lean on other reviewers for further review. Thank you!
// As an easy enhancement for later, we can also validate the request parameters on the front-end | ||
// instead of defaulting to '', to save a round trip. | ||
const req = new URLSearchParams(); | ||
req.append('cluster_id', cluster_id || ''); | ||
req.append('keyspace', keyspace || ''); | ||
req.append('sql', sql || ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we check these parameters in the component itself? Maybe disabling the 'Run VExplain' button if keyspace is not selected or SQL
is empty?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks , i have added client side validation to check and alert if sql
and keyspace
are empty. Please let me know.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I don't think we need alert
here, is it possible to simply disable the button until all the parameters are non-empty?
@@ -2505,6 +2508,82 @@ func (c *Cluster) ToggleTabletReplication(ctx context.Context, tablet *vtadminpb | |||
return err | |||
} | |||
|
|||
// GetVExplain returns the VExplain json message. | |||
func (c *Cluster) GetVExplain(ctx context.Context, req *vtadminpb.VExplainRequest, vexplainStmt *sqlparser.VExplainStmt) (*vtadminpb.VExplainResponse, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we need this to be here as it doesn't really need any property from c *Cluster
, maybe we can directly parse the result in c.DB.VExplain()
, then we won't need it to be here. So, this would include moving convertVExplainResultToString
and convertVExplainQueriesResultToString
to vtsql.go
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks , incorporated with a79c71f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this method from here, and call c.DB.VExplain
directly in api.go
?
Thanks @beingnoble03 for helping to review and share feedback. Will go over and incorporate before making PR ready for review. |
Signed-off-by: c-r-dev <[email protected]>
Signed-off-by: c-r-dev <[email protected]>
Signed-off-by: c-r-dev <[email protected]>
@systay , @beingnoble03 , @harshit-gangal , @deepthi , team, While testing changes locally , came across below scenario :
To resolve this , couple of diff ways I can think off :
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rest LGTM. Tested this locally as well, works as expected. Thank you!
|
||
// We don't particularly care to test the contents of the VExplain response, | ||
// just that it exists. | ||
print(resp.Response) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think this print statement can be removed?
// As an easy enhancement for later, we can also validate the request parameters on the front-end | ||
// instead of defaulting to '', to save a round trip. | ||
const req = new URLSearchParams(); | ||
req.append('cluster_id', cluster_id || ''); | ||
req.append('keyspace', keyspace || ''); | ||
req.append('sql', sql || ''); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I don't think we need alert
here, is it possible to simply disable the button until all the parameters are non-empty?
} | ||
func convertVExplainResultToString(rows *sql.Rows) (*vtadminpb.VExplainResponse, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think we can leave a line between these 2 functions.
@@ -2505,6 +2508,82 @@ func (c *Cluster) ToggleTabletReplication(ctx context.Context, tablet *vtadminpb | |||
return err | |||
} | |||
|
|||
// GetVExplain returns the VExplain json message. | |||
func (c *Cluster) GetVExplain(ctx context.Context, req *vtadminpb.VExplainRequest, vexplainStmt *sqlparser.VExplainStmt) (*vtadminpb.VExplainResponse, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this method from here, and call c.DB.VExplain
directly in api.go
?
Description
VTAdmin's VTExplain feature currently uses VTExplain directly.
With this PR introduced
A new end point in VTADMIN-API
/api/vexplain
, which leverages VTGate sql connection to runvexplain [ALL|PLAN|QUERIES|TRACE|KEYS] <QUERY>
( https://vitess.io/docs/22.0/user-guides/sql/vexplain/ )A new page in VTADMIN-WEB
/vexplain
which connect to VTADMIN-API/api/vexplain
.Please note - currently PR has
/vexplain
and/api/vexplain
, will merge/patch these over/vtexplain
and/api/vtexplain
based on feedback.While testing the changes on local , i came across below scenario , need inputs from team on #17508 (comment)
thanks to @beingnoble03 , i have tried to move things around and added a drop down for vexplain options with 4099f0e
Related Issue(s)
Fixes #16412
Checklist
Deployment Notes