Skip to content

Commit db8e9a8

Browse files
committed
Improve the docs
Signed-off-by: Matt Lord <mattalord@gmail.com>
1 parent 1f0b658 commit db8e9a8

1 file changed

Lines changed: 22 additions & 1 deletion

File tree

content/en/docs/18.0/reference/vreplication/movetables.md

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,10 +203,31 @@ If moving all tables, specifies tables to be skipped.
203203

204204
<div class="cmd">
205205

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.
207209

208210
</div>
209211

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.
229+
{{< /info>}}
230+
210231
#### --keep_data
211232
**optional**\
212233
**default** false

0 commit comments

Comments
 (0)