Tablet Selection
Introduction #
For both VTGate VStreams and VTTablet VReplication streams we must choose a tablet to serve the role of source (vstreamer). This
tablet selection is performed by the internal TabletPicker
component.
Cells and Cell Preference #
By default the TabletPicker
will only look for viable (healthy and serving) source tablets of the specified tablet type(s) within the local cell (or cell alias within which the local cell belongs) of the
calling process β the vtgate
managing the VStream or the target vttablet
for the VReplication stream β and it will select a random one from the candidate
list. If you want to support cross-cell streams then you will need to specify the list of cells or any
CellAlias that contain a list of cells using the --cells
flag in your VReplication
workflow commands like MoveTables
or the
VStreamFlags.Cells
field in a
VStreamRequest
.
Even with the --cells
flag specified, by default, the TabletPicker
will give preference to a healthy and serving tablet within the local cell of the calling process. If there are multiple candidates in the local cell, it will pick one at random. If no healthy tablets exist in the local cell pool, then it will give preference to tablets within cells belonging to the same cell alias as the local cell. If none exist here, then it moves on to selecting candidates from cells provided using the --cells
flag in your VReplication workflow commands.
When using the VTGate VStream API, you can override this local cell preference by specifying the CellPreference
field as onlyspecified
and a list of cells with Cells
in the VStreamFlags request object. This will then only pick tablets from the cells provided.
Tablet Types #
VReplication #
For VReplication the tablet types determines the candidate types made available for potential selection as the source for a stream (default value is in_order:REPLICA,PRIMARY
). The target tablet will provide this value to the TabletPicker
to determine the viable source tablet candidates. You specify the value on the client side using your
workflow command's --tablet-types
flag.
You can also specify that the tablet types should be used in the order of preference as listed in the --tablet-types
flag using the --tablet-types-in-preference-order
flag. For example --tablet-types "REPLICA,PRIMARY" --tablet-types-in-preference-order
would cause a replica source tablet to be used whenever possible
and a primary tablet would only be used as a fallback in the event that there are no viable replica tablets
available at the time.
TabletOrder
field in the VStreamFlags request object as usage of the "in_order" string hint will eventually be deprecated and removed.VStream #
For a VStream there is no default tablet type. You must specify an individual tablet type using the
VStreamRequest.TabletType
field.