--- SwitchTraffic
Switch traffic from source to target
Command #
MoveTables/Reshard -- [--tablet_types=<tablet_types>] [--cells=<cells>]
[--timeout=timeoutDuration] [--reverse_replication] [--dry_run]
SwitchTraffic <targetKs.workflow>
Description #
SwitchTraffic
switches traffic forward for the tablet_types specified. This replaces the previous SwitchReads and SwitchWrites commands with a single one. It is now possible to switch all traffic with just one command. Also, you can now switch replica, rdonly and primary traffic in any order: earlier you needed to first SwitchReads (for replicas and rdonly tablets) first before SwitchWrites.
Parameters #
--cells #
optional
default all cells
A comma-separated list of cell names or cell aliases. Traffic will be switched only in these cells for the specified tablet types.
--tablet_types #
optional
default all (in_order:RDONLY,REPLICA,PRIMARY)
A comma-separated list of tablet types for which traffic is to be switched.
One or more from primary,replica,rdonly.
--timeout #
optional
default 30s
For primary tablets, SwitchTraffic first stops writes on the source primary and waits for the replication to the target to catchup with the point where the writes were stopped. If the wait time is longer than timeout the command will error out. For setups with high write qps you may need to increase this value.
--reverse_replication #
optional
default true
SwitchTraffic for primary tablet types, by default, starts a reverse replication stream with the current target as the source, replicating back to the original source. This enables a quick and simple rollback using ReverseTraffic. This reverse workflow name is that of the original workflow concatenated with _reverse.
If set to false these reverse replication streams will not be created and you will not be able to rollback once you have switched write traffic over to the target.
--max_replication_lag_allowed #
optional
default the value used for --timeout
While switching traffic ensure that the VReplication lag for the workflow is less than this duration, otherwise report an error and don't attempt the switch. The calculated VReplication lag is the estimated maximum lag across workflow streams between the last event seen at the source and the last event processed by the target (which would be a heartbeat event if we're fully caught up). Usually, when VReplication has caught up, this lag should be very small (under a second).
While switching write traffic, we temporarily make the source databases read-only, and wait for the targets to catchup. This means that the application can effectively be partially down for this cutover period as writes will pause or error out. While switching write traffic this flag can ensure that you only switch traffic if the current lag is low, thus limiting this period of write-unavailability and avoiding it entirely if we're not likely to catch up within the --timeout
window.
While switching read traffic this can also be used to set an approximate upper bound on how stale reads will be against the replica tablets when using @replica
shard targeting.
--dry-run #
optional
default false