-
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
VReplication: send unique key name to rowstreamer
, which can then use with FORCE INDEX
#14916
Conversation
…ique_key, rowstreamer reads it and uses the value as FORCE INDEX hint Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
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
|
I'm suggesting this should be backported to supported versions. Opinions? |
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
bb1a991
to
a7d82b4
Compare
@@ -619,6 +620,7 @@ func (v *VRepl) analyzeBinlogSource(ctx context.Context) { | |||
SourceUniqueKeyColumns: encodeColumns(&v.chosenSourceUniqueKey.Columns), | |||
TargetUniqueKeyColumns: encodeColumns(&v.chosenTargetUniqueKey.Columns), | |||
SourceUniqueKeyTargetColumns: encodeColumns(v.chosenSourceUniqueKey.Columns.MappedNamesColumnList(v.sharedColumnsMap)), | |||
ForceUniqueKey: url.QueryEscape(v.chosenSourceUniqueKey.Name), |
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.
I'm curious why we're doing URL escaping?
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.
It's for when the index name has spaces, or quotes, or other special characters. The query hints parser will otherwise be unable to parse it correctly. Consider select /*vt+ ukForce="an index with spaces" */
-- the parser will only parse "an"
.
if directives == "" { | ||
return fmt.Sprintf(queryTemplate, "") | ||
} |
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.
These lines are unnecessary as the subsequent line would return the same thing when directives is an empty string.
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.
Removed redundant code.
{"", "force index (`PRIMARY`) order by id"}, | ||
{"/*vt+ ukColumns=\"uk1\" ukForce=\"uk2\" */", "force index (`uk2`) order by uk1"}, | ||
{"/*vt+ ukForce=\"uk2\" */", "force index (`uk2`) order by uk1"}, | ||
{"/*vt+ ukColumns=\"uk1\" */", "order by uk1"}, |
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.
I feel like we could probably use a few more test cases, but this might be enough.
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #14916 +/- ##
=======================================
Coverage ? 47.28%
=======================================
Files ? 1136
Lines ? 238493
Branches ? 0
=======================================
Hits ? 112761
Misses ? 117121
Partials ? 8611 ☔ View full report in Codecov by Sentry. |
IMO this should be backported to supported versions seeing that vstreamer could run into degraded/impossible performance situations. The fix itself is fairly safe. |
All backports have conflicts, that is expected. |
Description
Fixes #14915
This PR adds:
force_unique_key
field in filter/rule.rowstreamer
as query hint.rowstreamer
sees said query hint, then it addsFORCE INDEX (...)
to the streaming query.Note: still unsure what's the best way to add testing. The observable changes are that the rowstreamer query now includes a
force index
clause, e.g.:vstreamer/engine
populates the query hint like so:Related Issue(s)
#14915
Checklist
Deployment Notes