Skip to content

KR.ADMIN ROUTE

Manages shard-to-member routing for primary and standby assignments.

KR.ADMIN ROUTE <operation-kind> <route-kind> <shard-kind> <shard-id> <member-id>
ParameterTypeDescription
operation-kindstringSET or UNSET. Case-insensitive.
route-kindstringPRIMARY or STANDBY. Case-insensitive.
shard-kindstringSTASH or BUCKET. Case-insensitive.
shard-idinteger or *Zero-based shard index, or * to target all shards atomically.
member-idstringFull 40-character hex member ID or a 4-character prefix. A prefix is resolved against currently registered members.

Note: STASH is an experimental shard kind, disabled by default. See Stash in the configuration reference.

Simple string. Returns OK on success.

Requires cluster initialization.

Assigns a member as the primary owner of a shard.

When no primary is assigned yet, the member is written directly as the primary.

Reassignment, when a primary already exists, enforces strict pre-conditions:

  1. The shard status must not be READWRITE.
  2. The new primary must currently be a standby on that shard.
  3. The volume status must be READONLY.
  4. The standby must be fully caught up with the primary’s replication state.

On successful promotion the member is removed from the standby set.

Adds a member to the shard’s standby set. A primary must already be assigned. The member must not be the current primary and must not already be a standby.

Removes a member from the standby set. A primary must be assigned and the member must be in the standby set.

Not supported. Always returns an error.

When shard-id is *, the operation applies to every shard of the specified kind within a single FoundationDB transaction. If any shard fails a pre-condition, the entire transaction is rolled back.

Every successful mutation triggers the cluster topology watcher, causing other members to refresh their routing tables.

Argument errors:

Error CodeError messageCause
ERRinvalid number of parameters-
ERRUnknown operation kind: '<value>'The operation kind must be SET or UNSET.
ERRUnknown route kind: '<value>'The route kind must be PRIMARY or STANDBY.
ERRUnknown shard kind: '<value>'The shard kind must be STASH or BUCKET.
ERRinvalid shard idThe shard ID is not a valid integer, or is out of the configured range.
ERRInvalid memberId: <value>The value is neither a 40-character member ID nor a 4-character prefix.

Cluster errors:

Error CodeError messageCause
ERRcluster has not been initialized yet-
ERRno member found with prefix: <prefix>-
ERRmore than one member found with prefix: <prefix>-
ERRmember not found-
ERRno primary member assigned yetSET or UNSET STANDBY requires an existing primary.
ERRprimary cannot be assigned as a standby-
ERRalready assigned as a standby-
ERRmember is not a standby-
ERRUNSET PRIMARY is not supported-
ERRShard status must not be READWRITEReassigning a primary requires the shard to be non-READWRITE first.
ERRMember could not be found: <id>The target member could not be resolved during reassignment.
ERRPrimary shard owner could not be found: <id>The current primary could not be resolved during reassignment.
ERRMember id: <id> is not a standbyThe new primary must be a current standby during reassignment.
ERRVolume status must be READONLYThe volume must be READONLY before primary reassignment.
ERRStandby is not caught up: <details>The standby has not finished replicating from the primary. The detail indicates whether the lag is in the replication stage, segment position, or sequence number.

Assign a primary to a shard:

127.0.0.1:3320> KR.ADMIN ROUTE SET PRIMARY BUCKET 0 006cdc459c59e600c76494e8388857fc3cba2fa8
OK

Add a standby to a shard:

127.0.0.1:3320> KR.ADMIN ROUTE SET STANDBY BUCKET 0 a3f18b2e74d9c5601f82e4a7b390d612c8f7e149
OK

Assign a standby to all bucket shards:

127.0.0.1:3320> KR.ADMIN ROUTE SET STANDBY BUCKET * a3f18b2e74d9c5601f82e4a7b390d612c8f7e149
OK

Remove a standby from a shard:

127.0.0.1:3320> KR.ADMIN ROUTE UNSET STANDBY BUCKET 0 a3f18b2e74d9c5601f82e4a7b390d612c8f7e149
OK

Error: assigning standby without a primary

127.0.0.1:3320> KR.ADMIN ROUTE SET STANDBY BUCKET 0 a3f18b2e74d9c5601f82e4a7b390d612c8f7e149
(error) ERR no primary member assigned yet

Error: unsetting primary

127.0.0.1:3320> KR.ADMIN ROUTE UNSET PRIMARY BUCKET 0 006cdc459c59e600c76494e8388857fc3cba2fa8
(error) ERR UNSET PRIMARY is not supported