You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/18.0/reference/vreplication/movetables.md
+22-1Lines changed: 22 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -203,10 +203,31 @@ If moving all tables, specifies tables to be skipped.
203
203
204
204
<divclass="cmd">
205
205
206
-
When switching write (primary tablet) traffic for tables that are being moved from an unsharded keyspace to a sharded one, initialize any sequences being used by those tables on the target. They are initialized using the current maximum value for the column used on the target. This ensures that the sequence values on the target are greater than the maximum value seen on the source and ensure seamless auto generated primary key values when going from [MySQL auto_increment](https://dev.mysql.com/doc/refman/en/example-auto-increment.html) columns on the unsharded source to [Vitess Sequences](../../features/vitess-sequences/) on the sharded target.
206
+
If specified, when switching write (primary tablet) traffic for tables that are being moved from an unsharded keyspace to a
207
+
sharded one, initialize any sequences being used by those tables on the target. They are initialized using the current
208
+
maximum value for the column across all shards on the target.
207
209
208
210
</div>
209
211
212
+
###### Uses
213
+
214
+
* It's common that users import unsharded data into Vitess — sharding it in the process — or move
215
+
tables from an unsharded keyspace to a sharded one as they become too large for a single MySQL instance.
216
+
When doing either of these you would typically be leveraging [MySQL auto_increment](https://dev.mysql.com/doc/refman/en/example-auto-increment.html)
217
+
columns for primary keys on the unsharded tables (source). On the sharded target, however, you will then
218
+
need to use [Vitess Sequences](../../features/vitess-sequences/) in order to ensure that you continue having
219
+
automatically generated incrementing unique primary keys _across all shards_. When it comes to [switching the write traffic](#switchtraffic)
220
+
during this move you would need to manually ensure that you [initialize the sequences](../../features/vitess-sequences/#initializing-a-sequence)
221
+
so that the next values they provide are higher than any already used on the source (with ample buffer in between
222
+
to avoid potential identifier reuse and duplicate key errors immediately following the cutover). This flag tells Vitess
223
+
to manage this sequence initialization for you as part of the `SwitchTraffic` operation to ensure a seamless cutover
224
+
without any additional manual steps. For more information, please see [the feature request](https://github.com/vitessio/vitess/issues/13685).
225
+
226
+
{{< info >}}
227
+
You will still need to take the manual step of [creating each backing sequence table](../../features/vitess-sequences/#creating-a-sequence)
228
+
in an unsharded keyspace of your choosing prior to the `SwitchTraffic` operation.
0 commit comments