Skip to content
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

add support for vtgate traffic mirroring (queryserving) #15992

Merged

Conversation

maxenglander
Copy link
Collaborator

@maxenglander maxenglander commented May 22, 2024

Description

Query-serving component for #15945.

Related Issue(s)

#13772
#15945

Checklist

  • "Backport to:" labels have been added if this change should be back-ported to release branches
  • If this change is to be back-ported to previous releases, a justification is included in the PR description
  • Tests were added or are not required
  • Did the new or modified tests pass consistently locally and on CI?
  • Documentation was added: document mirror rules website#1744

Deployment Notes

Signed-off-by: Max Englander <max@planetscale.com>
Copy link
Contributor

vitess-bot bot commented May 22, 2024

Review Checklist

Hello reviewers! 👋 Please follow this checklist when reviewing this Pull Request.

General

  • Ensure that the Pull Request has a descriptive title.
  • Ensure there is a link to an issue (except for internal cleanup and flaky test fixes), new features should have an RFC that documents use cases and test cases.

Tests

  • Bug fixes should have at least one unit or end-to-end test, enhancement and new features should have a sufficient number of tests.

Documentation

  • Apply the release notes (needs details) label if users need to know about this change.
  • New features should be documented.
  • There should be some code comments as to why things are implemented the way they are.
  • There should be a comment at the top of each new or modified test to explain what the test does.

New flags

  • Is this flag really necessary?
  • Flag names must be clear and intuitive, use dashes (-), and have a clear help text.

If a workflow is added or modified:

  • Each item in Jobs should be named in order to mark it as required.
  • If the workflow needs to be marked as required, the maintainer team must be notified.

Backward compatibility

  • Protobuf changes should be wire-compatible.
  • Changes to _vt tables and RPCs need to be backward compatible.
  • RPC changes should be compatible with vitess-operator
  • If a flag is removed, then it should also be removed from vitess-operator and arewefastyet, if used there.
  • vtctl command output order should be stable and awk-able.

@vitess-bot vitess-bot bot added NeedsBackportReason If backport labels have been applied to a PR, a justification is required NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsIssue A linked issue is missing for this Pull Request NeedsWebsiteDocsUpdate What it says labels May 22, 2024
@github-actions github-actions bot added this to the v20.0.0 milestone May 22, 2024
@maxenglander maxenglander added Type: Feature Component: Query Serving and removed NeedsDescriptionUpdate The description is not clear or comprehensive enough, and needs work NeedsWebsiteDocsUpdate What it says NeedsIssue A linked issue is missing for this Pull Request NeedsBackportReason If backport labels have been applied to a PR, a justification is required labels May 22, 2024
Signed-off-by: Max Englander <max@planetscale.com>
Signed-off-by: Max Englander <max@planetscale.com>
Signed-off-by: Max Englander <max@planetscale.com>
Copy link

codecov bot commented Jun 18, 2024

Codecov Report

Attention: Patch coverage is 75.06361% with 98 lines in your changes missing coverage. Please review.

Project coverage is 68.88%. Comparing base (fae7540) to head (43b8c1a).
Report is 35 commits behind head on main.

Files with missing lines Patch % Lines
go/vt/vtgate/vindexes/vschema.go 79.08% 32 Missing ⚠️
go/vt/vtgate/vcursor_impl.go 23.52% 26 Missing ⚠️
go/vt/vtgate/planbuilder/operators/mirror.go 50.00% 17 Missing ⚠️
go/vt/vtgate/engine/mirror.go 79.31% 12 Missing ⚠️
go/vt/vtgate/planbuilder/operator_transformers.go 80.00% 2 Missing ⚠️
go/vt/vtgate/planbuilder/operators/ast_to_op.go 88.88% 2 Missing ⚠️
go/vt/vtgate/semantics/semantic_table.go 90.00% 2 Missing ⚠️
go/vt/vtgate/semantics/vtable.go 0.00% 2 Missing ⚠️
go/test/vschemawrapper/vschema_wrapper.go 87.50% 1 Missing ⚠️
go/vt/vtgate/planbuilder/operators/horizon.go 0.00% 1 Missing ⚠️
... and 1 more
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15992      +/-   ##
==========================================
+ Coverage   68.87%   68.88%   +0.01%     
==========================================
  Files        1562     1564       +2     
  Lines      200624   201012     +388     
==========================================
+ Hits       138179   138470     +291     
- Misses      62445    62542      +97     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@maxenglander maxenglander modified the milestones: v20.0.0, v21.0.0 Jun 19, 2024
maxenglander and others added 3 commits June 21, 2024 14:18
Co-authored-by: Deepthi Sigireddi <deepthi.sigireddi@gmail.com>
Signed-off-by: Max Englander <max.englander@gmail.com>
Co-authored-by: Deepthi Sigireddi <deepthi.sigireddi@gmail.com>
Signed-off-by: Max Englander <max.englander@gmail.com>
Signed-off-by: Max Englander <max@planetscale.com>
@maxenglander maxenglander force-pushed the maxeng-mirror-routingrules-queryserving branch from 083c9e1 to 9ed0b03 Compare June 21, 2024 23:32
Signed-off-by: Max Englander <max@planetscale.com>
Signed-off-by: Max Englander <max@planetscale.com>
@maxenglander maxenglander force-pushed the maxeng-mirror-routingrules-queryserving branch from 9ed0b03 to 2a786e5 Compare June 24, 2024 22:55
@maxenglander maxenglander changed the base branch from maxeng-mirror-routingrules to main July 1, 2024 17:30
Signed-off-by: Max Englander <max@planetscale.com>
@maxenglander maxenglander marked this pull request as ready for review July 1, 2024 18:22
Comment on lines 186 to 187
// ErrNotSingleTable refers to an error happening when something should be used only for single tables
var ErrNotSingleTable = vterrors.Errorf(vtrpcpb.Code_INTERNAL, "[BUG] should only be used for single tables")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: could use vterrors.VT13001

Comment on lines 1020 to 1026
mi := MirrorInfo{}
for _, t := range tableInfos {
if mr := t.GetMirrorRule(); mr != nil {
if mi.Percent == 0 || mr.Percent < mi.Percent {
mi.Percent = mr.Percent
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can specifically check for RealTable type here and check on the mirror rule.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you saying we can remove the GetMirrorRule method from TableInfo and just directly check for t.(*RealTable)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, we can type cast it and check the mirror rule

Comment on lines 46 to 65
cloneMirror := *m
cloneMirror.Percent = m.Percent
cloneMirror.Operator = inputs[0]
cloneMirror.Target = inputs[1]
return &cloneMirror
}

// Inputs returns the inputs for this operator
func (m *PercentBasedMirror) Inputs() []Operator {
return []Operator{
m.Operator,
m.Target,
}
}

// SetInputs changes the inputs for this op
func (m *PercentBasedMirror) SetInputs(inputs []Operator) {
m.Operator = inputs[0]
m.Target = inputs[1]
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: better to check the slice length before using indices.

Comment on lines 72 to 77
panic("not supported")
}

func (m *PercentBasedMirror) AddColumn(ctx *plancontext.PlanningContext, reuseExisting bool, addToGroupBy bool, expr *sqlparser.AliasedExpr) int {
panic("not supported")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: for all the panic send along and error inside, like panic(vterrors.VT13001(...))

Copy link
Member

@harshit-gangal harshit-gangal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

adding a test with mirror percentage 0, should be a good one to check plan without mirror operator.

Comment on lines 5 to 20
"from_table": "unsharded_src1.t1",
"to_table": "unsharded_dst1.t1",
"percent": 50
},
{
"from_table": "unsharded_src1.t2",
"to_table": "sharded_dst1.t1",
"percent": 50
},
{
"from_table": "unsharded_src2.t1",
"to_table": "unsharded_src2.t1",
"percent": 50
},
{
"from_table": "unsharded_src2.t2",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

having variable percentage would be a good to have, also to verify which percentage the plan selects

…s, return mirror keyspace

Signed-off-by: Max Englander <max@planetscale.com>
… case

Signed-off-by: Max Englander <max@planetscale.com>
Signed-off-by: Max Englander <max@planetscale.com>
Signed-off-by: Max Englander <max@planetscale.com>
Copy link
Member

@harshit-gangal harshit-gangal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR is looking good, added some more comments based on the changes.

maxenglander and others added 4 commits August 13, 2024 14:04
Signed-off-by: Max Englander <max@planetscale.com>
Signed-off-by: Max Englander <max@planetscale.com>
Co-authored-by: Harshit Gangal <harshit@planetscale.com>
Signed-off-by: Max Englander <max.englander@gmail.com>
Signed-off-by: Max Englander <max@planetscale.com>
Signed-off-by: Max Englander <max@planetscale.com>
@deepthi
Copy link
Member

deepthi commented Aug 27, 2024

Not sure why DCO check is still pending. I assume all the commits are correctly signed off. @maxenglander if you can confirm that, we can bypass and merge instead of a force-push -> Run CI all over again -> merge.

@maxenglander
Copy link
Collaborator Author

Hey @deepthi all the commits have the "Verified" sign on GH, and each commit individually has the Signed-off-by trailer from either max@planetscale.com or (for ones I merged from GH) max.englander@gmail.com, both of which are attached to my GH account. Not sure if there's something else I need to do to verify.

@deepthi deepthi merged commit fdb7f30 into vitessio:main Aug 28, 2024
128 checks passed
@deepthi deepthi deleted the maxeng-mirror-routingrules-queryserving branch August 28, 2024 16:58
venkatraju pushed a commit to slackhq/vitess that referenced this pull request Aug 29, 2024
Signed-off-by: Max Englander <max@planetscale.com>
Signed-off-by: Max Englander <max.englander@gmail.com>
Signed-off-by: Andres Taylor <andres@planetscale.com>
Co-authored-by: Deepthi Sigireddi <deepthi.sigireddi@gmail.com>
Co-authored-by: Andres Taylor <andres@planetscale.com>
Co-authored-by: Harshit Gangal <harshit@planetscale.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants