-
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
Migrate Workflow: Scope vindex names correctly when target and source keyspace have different names #16769
base: main
Are you sure you want to change the base?
Migrate Workflow: Scope vindex names correctly when target and source keyspace have different names #16769
Conversation
…names are different, we need to scope the vindex used in the vreplication filter to the local name Signed-off-by: Rohit Nayak <rohit@planetscale.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
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #16769 +/- ##
==========================================
+ Coverage 68.98% 69.53% +0.54%
==========================================
Files 1562 1568 +6
Lines 200697 202442 +1745
==========================================
+ Hits 138459 140764 +2305
+ Misses 62238 61678 -560 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
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.
In general it LGTM. I had some minor nits and suggestions, the only thing that I think we really should do is address the it is expected that the source and target keyspaces have the same vindex name and data type
part and confirm that ourselves. Unless there's some reason(s) that we cannot?
// TestShardedMigrate adds a test for a sharded cluster to validate a fix for a bug where the target keyspace name | ||
// doesn't match that of the source cluster. The test migrates from a cluster with keyspace customer to an "external" | ||
// cluster with keyspace rating. | ||
func TestMigrateSharded(t *testing.T) { |
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 don't see where this test is executed in the CI. Am I missing it? I can see that this test fails on main with:
=== NAME TestMigrateSharded
migrate_test.go:351: Migrate command failed with exit status 1 : E0917 21:04:21.580700 89860 main.go:56] rpc error: code = Unknown desc = node doesn't exist: /vitess/global/keyspaces/customer/shards/-80/Shard
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.
Fixed
@@ -165,7 +168,7 @@ func TestVtctlMigrate(t *testing.T) { | |||
// However now we need to create an external Vitess cluster. For this we need a different VTDATAROOT and | |||
// hence the VTDATAROOT env variable gets overwritten. | |||
// Each time we need to create vt processes in the "other" cluster we need to set the appropriate VTDATAROOT | |||
func TestVtctldMigrate(t *testing.T) { | |||
func TestVtctldMigrateUnsharded(t *testing.T) { |
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.
IMO, better to update this here as well:
test/config.json: "Args": ["vitess.io/vitess/go/test/endtoend/vreplication", "-run", "TestVtctldMigrate", "-timeout", "30m"],
It should still get run because the value is a regex but I'm not sure that we've intentionally relied on that in the CI.
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.
Changed name of second test to use TestVtctldMigrate
prefix. go test
is run here, so all tests with that prefix will be run. It keeps the config.json
smaller, esp since we are running both tests on same shard.
go/vt/wrangler/materializer.go
Outdated
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.
IMO we should not change the wrangler anymore on main.
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 have users from older Vitess versions who are using this and it will make it easier to backport to those versions.
"--target-keyspace", "rating", "--workflow", "e1", | ||
"create", "--source-keyspace", "customer", "--mount-name", "external", "--all-tables", "--cells=zone1", | ||
"--tablet-types=primary,replica"); err != nil { | ||
t.Fatalf("Migrate command failed with %+v : %s\n", err, output) |
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.
IMO we shouldn't use t.Fatal for new tests but instead require.Fail*
if mz.workflowType == binlogdatapb.VReplicationWorkflowType_Migrate { | ||
// For a Migrate, if the TargetKeyspace name is different from the SourceKeyspace name, we need to use the | ||
// SourceKeyspace name to determine the vindex since the TargetKeyspace name is not known to the source. | ||
// Note: it is expected that the source and target keyspaces have the same vindex name and data type. |
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 think that we should check and confirm this expectation and error out if it's not true.
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 is assumed that the vschemas and tables etc are identical on source and target for Migrate
. We can/should add all vaidations for this and all other workflow types in another PR. I don't want to add that to this PR.
// cluster with keyspace rating. | ||
func TestMigrateSharded(t *testing.T) { | ||
setSidecarDBName("_vt") | ||
defaultRdonly = 1 |
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.
Why set this? I don't see where we use it.
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.
This is that global variable that we have not refactored yet. It is used in creating future clusters in the test. Added code to keep previous values and reset in a defer.
} | ||
|
||
func setupExtKeyspace(t *testing.T, vc *VitessCluster, ksName, cellName string) { | ||
rdonly := 0 |
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.
Why not set replicas here as well and leave the global default for both alone? Then below:
if replicas > 0 {
require.NoError(t, vtgate.WaitForStatusOfTabletInShard(fmt.Sprintf("%s.%s.replica", ksName, shard), defaultReplicas, waitTimeout))
}
Leaving globals alone when we can and making each test deterministic seems best.
Signed-off-by: Rohit Nayak <rohit@planetscale.com>
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.
Nice work!
Description
We use the target keyspace’s vindex for filtering out rows from the source intended for each target shard. The vindex is qualified by the target keyspace name. When the source cluster has a different name for the keyspace, it fails while trying to stream from the source cluster, because it cannot locate the vindex.
This PR sets the vindex scope to that of the source keyspace if the keyspace names differ. Note that it is assumed that the same vindexes are used on both keyspaces during a
Migrate
Related Issue(s)
#16777
Checklist
Deployment Notes