-
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: Support automatically replacing auto_inc cols with sequences #16860
Changes from 17 commits
e6487dd
33b4cc9
e56dd5b
1cb3de5
f5eb4e2
b110120
6fc7fdc
e89bbf7
2b28b2b
659929e
cf99d54
292a422
8d5087a
4cbfb20
eaed239
ec94e1d
73f9491
733198b
67c1ef1
316a111
a56010e
cd7eea1
14b6873
3ceb253
2bb2a3a
1d8601a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,8 @@ var ( | |
NoRoutingRules bool | ||
AtomicCopy bool | ||
WorkflowOptions vtctldatapb.WorkflowOptions | ||
// This maps to a WorkflowOptions.StripShardedAutoIncrement ENUM value. | ||
StripShardedAutoIncrementStr string | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Along with the proto name change, we should change this name. It is confusing to call it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There seems to be some nuance here that I missed during review. So maybe you just need to explain what I'm missing :)
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. I'll rename it to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried to address this here: 733198b
mattlord marked this conversation as resolved.
Show resolved
Hide resolved
|
||
}{} | ||
|
||
// create makes a MoveTablesCreate gRPC call to a vtctld. | ||
|
@@ -87,6 +89,19 @@ var ( | |
return fmt.Errorf("cannot specify both --tenant-id (i.e. a multi-tenant migration) and --source-shards (i.e. a shard-by-shard migration)") | ||
} | ||
|
||
// createOptions.StripShardedAutoIncrementStr is the CLI flag value provided and | ||
// we need to map that to the ENUM value for createOptions.WorkflowOptions.StripShardedAutoIncrement | ||
// which gets saved in the _vt.vreplication record's options column. | ||
createOptions.StripShardedAutoIncrementStr = strings.ToUpper(createOptions.StripShardedAutoIncrementStr) | ||
val, ok := vtctldatapb.ShardedAutoIncrementHandling_value[createOptions.StripShardedAutoIncrementStr] | ||
if !ok { | ||
return fmt.Errorf("invalid value provided for --strip-sharded-auto-increment, valid values are: %s", stripShardedAutoIncStrOptions) | ||
} | ||
createOptions.WorkflowOptions.StripShardedAutoIncrement = vtctldatapb.ShardedAutoIncrementHandling(val) | ||
if val == int32(vtctldatapb.ShardedAutoIncrementHandling_REPLACE) && createOptions.WorkflowOptions.GlobalKeyspace == "" { | ||
fmt.Println("WARNING: no global-keyspace value provided so all sequence table references not fully qualified must be created manually before switching traffic") | ||
} | ||
|
||
return nil | ||
}, | ||
RunE: commandCreate, | ||
|
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 unclear exactly what the boolean logic here means to someone who doesn't already know it.
I'm reading it as
but it should be rewritten to avoid confusion.
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 can think about how to make it more clear. It reads pretty clear to me but I'll think about 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.
I tried to address this here: 733198b
The change is subtle, but I think it's quite clear.