-
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
Workflow Status: change logic to determine whether MoveTables
writes are switched
#16731
Workflow Status: change logic to determine whether MoveTables
writes are switched
#16731
Conversation
…ting rule state for given workflow Signed-off-by: Rohit Nayak <[email protected]>
…o check for where writes are routed Signed-off-by: Rohit Nayak <[email protected]>
…rget keyspaces. Add test to simulate this in routing rules Signed-off-by: Rohit Nayak <[email protected]>
Signed-off-by: Rohit Nayak <[email protected]>
Signed-off-by: Rohit Nayak <[email protected]>
Signed-off-by: Rohit Nayak <[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
|
Signed-off-by: Rohit Nayak <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16731 +/- ##
==========================================
- Coverage 68.98% 68.92% -0.06%
==========================================
Files 1562 1565 +3
Lines 200690 201748 +1058
==========================================
+ Hits 138449 139058 +609
- Misses 62241 62690 +449 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Rohit Nayak <[email protected]>
go/vt/vtctl/workflow/server.go
Outdated
rr := globalRules[fmt.Sprintf("%s.%s", sourceKeyspace, table)] | ||
if len(rr) > 0 && rr[0] != fmt.Sprintf("%s.%s", sourceKeyspace, table) { |
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.
We can calculate this key once. That's more efficient and prevents any accidental drift.
topodatapb "vitess.io/vitess/go/vt/proto/topodata" | ||
) | ||
|
||
func setupMoveTables(t *testing.T, ctx context.Context) *testEnv { |
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.
Is this really usable outside of this file and its test? If not, better IMO to include it in the test (can be a func var).
Signed-off-by: Rohit Nayak <[email protected]>
Description
We use the table routing rules to decide where reads and writes are routed for tables which are part of
MoveTables
workflows.For each table we have rules like
when no traffic is switched, or when all traffic is switched:
To determine whether writes are switched, we check the route for
t1
. If it is pointing totarget
it is considered that writes have been switched.The problem comes the same table exists in different source keyspaces. For example if there are two workflows one from
source1
=>target1
and another fromsource2
=>target2
, both with a tablet1
.Now if one workflow's writes are switched we end up with the route for
t1
pointing totarget1.t1
. When the next workflow's writes are switched we now overwrite that rule so that it points totarget2.t1
. The logic now assumes writes for the first workflow have not been switched.Fix:
In general, global routing rules don't make sense in such cases. But as an initial quick fix we change the logic to looking at the
source.t1
key instead oft1
. In our case then after the two workflows have been switched we will getsource1.t1
=>target1.t1
andsource2.t1
=>target2.t1
, resulting in the right state being deduced.We do the same for for
replica
/rdonly
types as well.Related Issue(s)
Checklist