Reshard

split or merge shards in a keyspace

Command #

Reshard -v1 [-cells=<cells>] [-tablet_types=<source_tablet_types>] [-skip_schema_copy] [-auto_start] [-stop_after_copy] <keyspace.workflow> <source_shards> <target_shards>

Description #

Reshard support horizontal sharding by letting you change the sharding ranges of your existing keyspace.

Parameters #

-cells #

optional\

Comma separated Cell(s) or CellAlias(es) to replicate from.

-tablet_types #

optional
default empty

Source Vitess tablet_type, or comma separated list of tablet types, that should be used for choosing source tablet(s) for the reshard.

Note: If replicating from primary, you must explicitly use -tablet_types=primary. If not specified, it defaults to the tablet type(s) specified by the -vreplication_tablet_type VTTablet command line flag. -vreplication_tablet_type defaults to "PRIMARY,REPLICA".

-skip_schema_copy #

optional
default false

If true the source schema is copied to the target shards. If false, you need to create the tables before calling reshard.

-auto_start #

optional
default true

If false, streams will start in the Stopped state and will need to be explicitly started (default true).

-stop_after_copy #

optional
default false

Streams will be stopped once the copy phase is completed.

keyspace.workflow #

mandatory

Name of keyspace being sharded and the associated workflow name, used in later commands to refer back to this reshard.

source_shards #

mandatory

Comma separated shard names to reshard from.

target_shards #

mandatory

Comma separated shard names to reshard to.

A Reshard Workflow #

Once you decide on the new resharding strategy for a keyspace, you need to initiate a VReplication workflow as follows:

  1. Initiate the migration using Reshard
  2. Monitor the workflow using Workflow or VExec
  3. Confirm that data has been copied over correctly using VDiff
  4. Start the cutover by routing all reads from your application to those tables using SwitchReads
  5. Complete the cutover by routing all writes using SwitchWrites
  6. Optionally cleanup the source tables using DropSources