Skip to content

CommandRoutingService ​

Whole commands carried from the member a client reached (the ingress) to the member that executes them: an autonomous statement, or a step of an interactive transaction at the leader, which alone holds open transactions. The executing member selects the view, evaluates, validates and commits; the ingress never ships a write set it evaluated itself.

Served only on the inter-node channel, to admitted members of the same deployment; a client credential never reaches it, and an admitted member is not by that alone allowed to act as any caller: each command names the caller its ingress verified. A call is never forwarded again: a member that cannot run it answers with a refusal naming the leader it knows of, and the ingress decides whether to try once more.

Values (parameters and rows) travel in the engine's own encoding, MessagePack of its value type: both members run the same version, which the version handshake establishes before any call here.

A command that ran and failed answers with its RoutedError, never with a refusal: a refusal means the command did not run. The ingress names the version of the RoutedError encoding it reads in the session's cn-routed-error-codec metadata (a decimal number); a member with another one refuses the session before reading any command of it.

Methods ​

Session ​

One long-lived stream between an ingress and a member that carries every command the ingress routes there and their answers, each tagged with the ingress's number for the command, so a command costs one message each way and no call of its own. Commands run concurrently; the order of the commands of one transaction is kept as for separate calls: the ingress sends the next only once the previous one is admitted.

The member rechecks the ingress's admission before each command it reads. A statement's answer streams in frames, at most as many ahead of the ingress as the credits it gave, so a slowly read answer holds back its own statement and no other. When the stream ends, every command still in flight stops at the member, and a transaction one of them ran in is aborted; the ingress cannot know what those commands did.

Transport: Server-streaming gRPC only (no HTTP transcoding)

Request: stream RoutedRequest

FieldTypeDescription
calluint64The ingress's number for the command, unique among the session's commands; the replies to the command carry it.
namespacestringThe name of the namespace the command's client session is bound to: the member runs a statement, begin, commit or rollback in that namespace and no other. Required for those commands, which are refused without it; ignored for operation calls (the deployment's), credit and cancel.
executeRoutedStatementRun a statement. Its answer is a series of frames; the member sends FRAMES_AHEAD (4) of them before it waits for credit.
beginRoutedBeginOpen an interactive transaction at the leader under the ID the client drew.
commitRoutedCommitCommit an interactive transaction at the leader.
rollbackRoutedRollbackRoll back an interactive transaction at the leader.
operationRoutedOperationEnroll an issuer, resolve an operation, or release or retire operation records at the leader, which decides them through the group's log.
credituint32The ingress took this many more frames of the statement's answer: the member may send as many more.
cancelRoutedCancelThe ingress no longer reads the statement's answer: the statement stops, and a transaction it ran in is aborted.

Response: stream RoutedReply

FieldTypeDescription
calluint64The number the ingress gave the command this answers.
frameRoutedStatementFrameEvents of a statement's answer; the frame that holds its end or error event is its last.
begunRoutedBegunThe answer to a begin.
committedRoutedCommittedThe answer to a commit.
rolled_backRoutedRolledBackThe answer to a rollback.
operationRoutedOperationAnswerThe answer to an operation call.
refusedRoutedRefusalThe member refused the command before running it: it did not run.
brokenstringThe answer broke after it began (a row that could not be encoded): what the command did is unknown. The text says what broke.

Types ​

ActingContext ​

Who a routed command acts for, as the ingress's authentication or its trusted host established it. Never taken from a client's request fields.

FieldTypeDescription
trustedTrustedEvery caller shares one trust boundary: an embedding host's own access, or a deployment configured without principals. No caller isolation.
principalPrincipalA verified principal.

Admitted ​

Carries nothing: the event is the signal.

No fields.

Columns ​

A result's column names, in order.

FieldTypeDescription
namesstring[]—

Principal ​

A verified subject and the scope it acts in.

FieldTypeDescription
subjectstringThe stable subject, as its issuer names it.
trust_scopestringThe issuer or trust scope the subject belongs to.
namespacestringThe namespace the caller is bound to.

RoutedBegin ​

Open an interactive transaction.

FieldTypeDescription
transaction_idbytesThe ID the client drew for it, 16 bytes.
actorActingContextWho the transaction acts for; every later command must act for the same.
settingsRoutedSettingsIts read concern level and write concern, fixed for its life; the read position fields are unused.
timeout_outcomeuint32What ends it when it stays idle past the idle timeout: 1 rolls it back, 2 commits it; zero takes the executing member's setting.
operationbytesThe client operation its commit carries out, in the descriptor's byte form; empty for none. Required to commit it at idle expiry.

RoutedBegun ​

Whether the transaction is open.

FieldTypeDescription
errorbytesEmpty when the transaction is open; otherwise why it was not opened, a RoutedError in its protobuf encoding, at most 64 KiB.

RoutedCancel ​

Carries nothing: the message is the signal.

No fields.

RoutedCommit ​

Commit an interactive transaction.

FieldTypeDescription
actorActingContextWho the commit acts for.
transaction_idbytesThe transaction's ID, 16 bytes.
operationbytesThe client operation the commit carries out, in the descriptor's byte form; empty for the one its begin named, or none.
deadline_msuint64What is left of the caller's deadline, in milliseconds; zero for none.
expectRoutedExpectation[]The node versions the caller built its statements on: a node at another version refuses the whole commit.

RoutedCommitted ​

The commit's receipt, or why it failed.

FieldTypeDescription
commit_tsuint64Timestamp every write of the transaction landed at; unset when error is set.
applied_indexuint64Log index the commit was applied at; zero when it reported none.
errorbytesEmpty when the commit succeeded; otherwise how it failed, a RoutedError in its protobuf encoding, at most 64 KiB.

RoutedDone ​

Carries nothing: the call is done.

No fields.

RoutedEnrolled ​

An enrolled incarnation.

FieldTypeDescription
incarnationuint64Its number.
next_sequenceuint64The first operation number it hands out.
deploymentbytesThe deployment that enrolled it, 16 bytes.

RoutedExpectation ​

A node and the version a caller believes it is at.

FieldTypeDescription
node_iduint64The node's id.
versionuint64The version read earlier; absent requires the node not to exist.

RoutedOperation ​

One call on the records of client operations.

FieldTypeDescription
actorActingContextWho the call acts for.
enrollbytesEnroll a new incarnation of this issuer, its 16 bytes.
resolveRoutedResolveResolve an operation's outcome.
acknowledgeRoutedOperationsRelease the outcomes of these settled operations.
retirebytesRetire the operations of this descriptor's incarnation numbered below its sequence, in the descriptor's byte form.

RoutedOperationAnswer ​

The answer to a call on operation records.

FieldTypeDescription
enrolledRoutedEnrolledThe incarnation an enrollment opened.
outcomeRoutedOutcomeHow a resolved operation stands.
doneRoutedDoneA release or retirement is done.
errorbytesThe call failed: a RoutedError in its protobuf encoding, at most 64 KiB.

RoutedOperations ​

Several operations.

FieldTypeDescription
operationsbytes[]Each in the descriptor's byte form.

RoutedOutcome ​

How an operation stands.

FieldTypeDescription
stateRoutedOperationState—
attemptuint64The attempt that committed; zero unless committed.
commit_tsuint64Its commit timestamp; zero unless committed.

RoutedPosition ​

A position in one history's log.

FieldTypeDescription
deploymentbytesThe deployment the history belongs to, 16 bytes.
groupuint64The group within it.
indexuint64The log index.

RoutedRefusal ​

Why a member did not run a command.

FieldTypeDescription
reasonstringWhat was refused: "request" for a command that does not decode, "admission" for an ingress no longer admitted, "duplicate" for a number already in flight on the session.
messagestringThe member's account of it.

RoutedReply ​

One message from the member on a session.

FieldTypeDescription
calluint64The number the ingress gave the command this answers.
frameRoutedStatementFrameEvents of a statement's answer; the frame that holds its end or error event is its last.
begunRoutedBegunThe answer to a begin.
committedRoutedCommittedThe answer to a commit.
rolled_backRoutedRolledBackThe answer to a rollback.
operationRoutedOperationAnswerThe answer to an operation call.
refusedRoutedRefusalThe member refused the command before running it: it did not run.
brokenstringThe answer broke after it began (a row that could not be encoded): what the command did is unknown. The text says what broke.

RoutedRequest ​

One message from the ingress on a session.

FieldTypeDescription
calluint64The ingress's number for the command, unique among the session's commands; the replies to the command carry it.
namespacestringThe name of the namespace the command's client session is bound to: the member runs a statement, begin, commit or rollback in that namespace and no other. Required for those commands, which are refused without it; ignored for operation calls (the deployment's), credit and cancel.
executeRoutedStatementRun a statement. Its answer is a series of frames; the member sends FRAMES_AHEAD (4) of them before it waits for credit.
beginRoutedBeginOpen an interactive transaction at the leader under the ID the client drew.
commitRoutedCommitCommit an interactive transaction at the leader.
rollbackRoutedRollbackRoll back an interactive transaction at the leader.
operationRoutedOperationEnroll an issuer, resolve an operation, or release or retire operation records at the leader, which decides them through the group's log.
credituint32The ingress took this many more frames of the statement's answer: the member may send as many more.
cancelRoutedCancelThe ingress no longer reads the statement's answer: the statement stops, and a transaction it ran in is aborted.

RoutedResolve ​

Resolve one operation.

FieldTypeDescription
operationbytesThe operation, in the descriptor's byte form.
excludeboolExclude it through the log when nothing is recorded of it, so the answer is final.

RoutedRollback ​

Roll back an interactive transaction.

FieldTypeDescription
actorActingContextWho the rollback acts for.
transaction_idbytesThe transaction's ID, 16 bytes.
abandonedboolThe client did not ask for it: the stream a statement of the transaction ran on was lost, so the transaction is aborted and later commands for it are told so.

RoutedRolledBack ​

Whether the rollback is done.

FieldTypeDescription
errorbytesEmpty when the rollback is done; otherwise why it was refused, a RoutedError in its protobuf encoding, at most 64 KiB.

RoutedSettings ​

The settings a statement runs under, as the statement, its session and the ingress's defaults named them. A setting left unset here takes the executing member's own.

FieldTypeDescription
read_concern_leveluint32Read concern level, numbered as coordinode.v1.replication.ReadConcernLevel (1 local, 2 majority, 3 linearizable, 4 snapshot); zero takes the executing member's default.
after_tsuint64Causal lower bound: the read is taken where every commit at or below this timestamp is applied; zero is no bound.
after_positionRoutedPositionCausal position in one history's log; absent is no bound.
causal_wait_msuint32How long the read may wait for a causal bound not met yet, in milliseconds; zero refuses it as not ready at once. A forwarded read carries what its ingress left of its wait, one budget for both.
at_timestampuint64Timestamp a snapshot read is pinned to; zero pins none.
write_concernRoutedWriteConcernWhen a write is acknowledged; absent takes the executing member's default.
vector_consistencyuint32Vector consistency, numbered as coordinode.v1.replication.VectorConsistency; zero leaves it to what the read concern implies.
vector_build_wait_msuint64How long the statement waits for a vector index still being built, in milliseconds; absent takes the executing member's setting.
query_memory_limituint64Memory limit of the statement in bytes; absent takes the executing member's setting.
read_preferenceuint32The members the read may be served by, numbered as coordinode.v1.replication.ReadPreference (1 primary, 2 primary preferred, 3 secondary, 4 secondary preferred, 5 nearest). A read forwarded because its ingress was behind its bound carries the preference it was sent with, which the executing member checks against its own role; zero reads at the leader, as a statement routed there for leadership does.

RoutedStart ​

How the command that starts a transaction opens it.

FieldTypeDescription
settingsRoutedSettingsIts read concern level and write concern, fixed for its life; the read position fields are unused.
timeout_outcomeuint32What ends it when it stays idle past the idle timeout: 1 rolls it back, 2 commits it; zero takes the executing member's setting.
operationbytesThe client operation its commit carries out, in the descriptor's byte form; empty for none. Required to commit it at idle expiry.

RoutedStatement ​

One statement to run at the member that executes it.

FieldTypeDescription
actorActingContextWho the statement acts for.
querystringThe statement's text.
parametersbytesIts parameters, a map from name to value in the engine's encoding; empty for none.
settingsRoutedSettingsThe settings it runs under.
transaction_idbytesThe ID of the interactive transaction it runs in, as the client drew it (16 bytes); empty for a statement that commits on its own.
operationbytesThe client operation an autonomous statement carries out, in the descriptor's byte form; empty for none.
deadline_msuint64What is left of the caller's deadline, in milliseconds; zero for none.
sourceSourceLocationWhere in the client's code the statement was issued, for the executing member's advisor; absent when the client sent none.
startRoutedStartPresent on the first statement of a transaction: the transaction opens with these settings under transaction_id, and the statement runs in it, in the one call; no separate Begin travels first. A start naming an open ID is refused before the statement runs.

RoutedStatementEvent ​

One event of a routed statement's answer.

FieldTypeDescription
admittedAdmittedA statement of a transaction has its place; the ingress may pass the next command of the same transaction on. A statement that commits on its own waits behind nothing and is answered without it.
columnsColumnsThe result's column names, before its first rows.
rowsbytesA batch of rows, each a list of values in the engine's encoding.
endRoutedStatsThe statistics that end the answer.
errorbytesThe failure that ends the answer: a RoutedError in its protobuf encoding, at most 64 KiB. Rows sent before it are not a result.

RoutedStatementFrame ​

The events of a routed statement's answer that were ready together, in order: an answer that fits one batch travels as one message.

FieldTypeDescription
eventsRoutedStatementEvent[]—

RoutedStats ​

What a finished statement reports.

FieldTypeDescription
nodes_createdint64—
nodes_deletedint64—
edges_createdint64—
edges_deletedint64—
properties_setint64—
applied_indexuint64Log index the statement's own commit was applied at; zero for none.
commit_tsuint64Timestamp the statement's own commit landed at; zero for none.
read_indexuint64Log index the read was served at on the executing member.
read_as_of_tsuint64What a read on a read-only member is as of; zero otherwise.
read_tsuint64The timestamp the statement read at: every commit at or below it that its view held; zero for none.
served_by_leaderboolWhether the executing member led its group when it served the statement: a read forwarded to a follower is not served by the leader.

RoutedWriteConcern ​

When a write is acknowledged.

FieldTypeDescription
acksuint32Members that must hold the write, the leader included, when majority is false; zero answers without waiting for any.
majorityboolA majority of the group must hold the write; acks is then unused.
journaluint32The state each counted member holds the write in, numbered as coordinode.v1.replication.Journal (1 journal, 2 cache, 3 memory).
timeout_msuint32Milliseconds to wait for the counted members; zero waits without bound.

SourceLocation ​

A place in the client's source code, sent by a driver in debug mode.

FieldTypeDescription
filestringSource file path as the client knows it.
lineuint32Line number in that file, starting at 1.
functionstringEnclosing function or method name; empty when the client cannot tell.

Trusted ​

The single-trust access mode; carries nothing.

No fields.

Enums ​

RoutedOperationState ​

The states an operation is in.

ValueNumberDescription
ROUTED_OPERATION_STATE_UNSPECIFIED0—
ROUTED_OPERATION_STATE_COMMITTED1An attempt of it committed.
ROUTED_OPERATION_STATE_ABORTED2It is proven never to take effect.
ROUTED_OPERATION_STATE_UNKNOWN3Nothing is recorded of it.
ROUTED_OPERATION_STATE_RETIRED4Its record is released.