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.
Proto source
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
| Field | Type | Description |
|---|---|---|
call | uint64 | The ingress's number for the command, unique among the session's commands; the replies to the command carry it. |
namespace | string | The 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. |
execute | RoutedStatement | Run a statement. Its answer is a series of frames; the member sends FRAMES_AHEAD (4) of them before it waits for credit. |
begin | RoutedBegin | Open an interactive transaction at the leader under the ID the client drew. |
commit | RoutedCommit | Commit an interactive transaction at the leader. |
rollback | RoutedRollback | Roll back an interactive transaction at the leader. |
operation | RoutedOperation | Enroll an issuer, resolve an operation, or release or retire operation records at the leader, which decides them through the group's log. |
credit | uint32 | The ingress took this many more frames of the statement's answer: the member may send as many more. |
cancel | RoutedCancel | The ingress no longer reads the statement's answer: the statement stops, and a transaction it ran in is aborted. |
Response: stream RoutedReply
| Field | Type | Description |
|---|---|---|
call | uint64 | The number the ingress gave the command this answers. |
frame | RoutedStatementFrame | Events of a statement's answer; the frame that holds its end or error event is its last. |
begun | RoutedBegun | The answer to a begin. |
committed | RoutedCommitted | The answer to a commit. |
rolled_back | RoutedRolledBack | The answer to a rollback. |
operation | RoutedOperationAnswer | The answer to an operation call. |
refused | RoutedRefusal | The member refused the command before running it: it did not run. |
broken | string | The 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.
| Field | Type | Description |
|---|---|---|
trusted | Trusted | Every caller shares one trust boundary: an embedding host's own access, or a deployment configured without principals. No caller isolation. |
principal | Principal | A verified principal. |
Admitted
Carries nothing: the event is the signal.
No fields.
Columns
A result's column names, in order.
| Field | Type | Description |
|---|---|---|
names | string[] | — |
Principal
A verified subject and the scope it acts in.
| Field | Type | Description |
|---|---|---|
subject | string | The stable subject, as its issuer names it. |
trust_scope | string | The issuer or trust scope the subject belongs to. |
namespace | string | The namespace the caller is bound to. |
RoutedBegin
Open an interactive transaction.
| Field | Type | Description |
|---|---|---|
transaction_id | bytes | The ID the client drew for it, 16 bytes. |
actor | ActingContext | Who the transaction acts for; every later command must act for the same. |
settings | RoutedSettings | Its read concern level and write concern, fixed for its life; the read position fields are unused. |
timeout_outcome | uint32 | What ends it when it stays idle past the idle timeout: 1 rolls it back, 2 commits it; zero takes the executing member's setting. |
operation | bytes | The 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.
| Field | Type | Description |
|---|---|---|
error | bytes | Empty 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.
| Field | Type | Description |
|---|---|---|
actor | ActingContext | Who the commit acts for. |
transaction_id | bytes | The transaction's ID, 16 bytes. |
operation | bytes | The client operation the commit carries out, in the descriptor's byte form; empty for the one its begin named, or none. |
deadline_ms | uint64 | What is left of the caller's deadline, in milliseconds; zero for none. |
expect | RoutedExpectation[] | 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.
| Field | Type | Description |
|---|---|---|
commit_ts | uint64 | Timestamp every write of the transaction landed at; unset when error is set. |
applied_index | uint64 | Log index the commit was applied at; zero when it reported none. |
error | bytes | Empty 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.
| Field | Type | Description |
|---|---|---|
incarnation | uint64 | Its number. |
next_sequence | uint64 | The first operation number it hands out. |
deployment | bytes | The deployment that enrolled it, 16 bytes. |
RoutedExpectation
A node and the version a caller believes it is at.
| Field | Type | Description |
|---|---|---|
node_id | uint64 | The node's id. |
version | uint64 | The version read earlier; absent requires the node not to exist. |
RoutedOperation
One call on the records of client operations.
| Field | Type | Description |
|---|---|---|
actor | ActingContext | Who the call acts for. |
enroll | bytes | Enroll a new incarnation of this issuer, its 16 bytes. |
resolve | RoutedResolve | Resolve an operation's outcome. |
acknowledge | RoutedOperations | Release the outcomes of these settled operations. |
retire | bytes | Retire 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.
| Field | Type | Description |
|---|---|---|
enrolled | RoutedEnrolled | The incarnation an enrollment opened. |
outcome | RoutedOutcome | How a resolved operation stands. |
done | RoutedDone | A release or retirement is done. |
error | bytes | The call failed: a RoutedError in its protobuf encoding, at most 64 KiB. |
RoutedOperations
Several operations.
| Field | Type | Description |
|---|---|---|
operations | bytes[] | Each in the descriptor's byte form. |
RoutedOutcome
How an operation stands.
| Field | Type | Description |
|---|---|---|
state | RoutedOperationState | — |
attempt | uint64 | The attempt that committed; zero unless committed. |
commit_ts | uint64 | Its commit timestamp; zero unless committed. |
RoutedPosition
A position in one history's log.
| Field | Type | Description |
|---|---|---|
deployment | bytes | The deployment the history belongs to, 16 bytes. |
group | uint64 | The group within it. |
index | uint64 | The log index. |
RoutedRefusal
Why a member did not run a command.
| Field | Type | Description |
|---|---|---|
reason | string | What 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. |
message | string | The member's account of it. |
RoutedReply
One message from the member on a session.
| Field | Type | Description |
|---|---|---|
call | uint64 | The number the ingress gave the command this answers. |
frame | RoutedStatementFrame | Events of a statement's answer; the frame that holds its end or error event is its last. |
begun | RoutedBegun | The answer to a begin. |
committed | RoutedCommitted | The answer to a commit. |
rolled_back | RoutedRolledBack | The answer to a rollback. |
operation | RoutedOperationAnswer | The answer to an operation call. |
refused | RoutedRefusal | The member refused the command before running it: it did not run. |
broken | string | The 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.
| Field | Type | Description |
|---|---|---|
call | uint64 | The ingress's number for the command, unique among the session's commands; the replies to the command carry it. |
namespace | string | The 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. |
execute | RoutedStatement | Run a statement. Its answer is a series of frames; the member sends FRAMES_AHEAD (4) of them before it waits for credit. |
begin | RoutedBegin | Open an interactive transaction at the leader under the ID the client drew. |
commit | RoutedCommit | Commit an interactive transaction at the leader. |
rollback | RoutedRollback | Roll back an interactive transaction at the leader. |
operation | RoutedOperation | Enroll an issuer, resolve an operation, or release or retire operation records at the leader, which decides them through the group's log. |
credit | uint32 | The ingress took this many more frames of the statement's answer: the member may send as many more. |
cancel | RoutedCancel | The ingress no longer reads the statement's answer: the statement stops, and a transaction it ran in is aborted. |
RoutedResolve
Resolve one operation.
| Field | Type | Description |
|---|---|---|
operation | bytes | The operation, in the descriptor's byte form. |
exclude | bool | Exclude it through the log when nothing is recorded of it, so the answer is final. |
RoutedRollback
Roll back an interactive transaction.
| Field | Type | Description |
|---|---|---|
actor | ActingContext | Who the rollback acts for. |
transaction_id | bytes | The transaction's ID, 16 bytes. |
abandoned | bool | The 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.
| Field | Type | Description |
|---|---|---|
error | bytes | Empty 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.
| Field | Type | Description |
|---|---|---|
read_concern_level | uint32 | Read concern level, numbered as coordinode.v1.replication.ReadConcernLevel (1 local, 2 majority, 3 linearizable, 4 snapshot); zero takes the executing member's default. |
after_ts | uint64 | Causal lower bound: the read is taken where every commit at or below this timestamp is applied; zero is no bound. |
after_position | RoutedPosition | Causal position in one history's log; absent is no bound. |
causal_wait_ms | uint32 | How 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_timestamp | uint64 | Timestamp a snapshot read is pinned to; zero pins none. |
write_concern | RoutedWriteConcern | When a write is acknowledged; absent takes the executing member's default. |
vector_consistency | uint32 | Vector consistency, numbered as coordinode.v1.replication.VectorConsistency; zero leaves it to what the read concern implies. |
vector_build_wait_ms | uint64 | How long the statement waits for a vector index still being built, in milliseconds; absent takes the executing member's setting. |
query_memory_limit | uint64 | Memory limit of the statement in bytes; absent takes the executing member's setting. |
read_preference | uint32 | The 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.
| Field | Type | Description |
|---|---|---|
settings | RoutedSettings | Its read concern level and write concern, fixed for its life; the read position fields are unused. |
timeout_outcome | uint32 | What ends it when it stays idle past the idle timeout: 1 rolls it back, 2 commits it; zero takes the executing member's setting. |
operation | bytes | The 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.
| Field | Type | Description |
|---|---|---|
actor | ActingContext | Who the statement acts for. |
query | string | The statement's text. |
parameters | bytes | Its parameters, a map from name to value in the engine's encoding; empty for none. |
settings | RoutedSettings | The settings it runs under. |
transaction_id | bytes | The ID of the interactive transaction it runs in, as the client drew it (16 bytes); empty for a statement that commits on its own. |
operation | bytes | The client operation an autonomous statement carries out, in the descriptor's byte form; empty for none. |
deadline_ms | uint64 | What is left of the caller's deadline, in milliseconds; zero for none. |
source | SourceLocation | Where in the client's code the statement was issued, for the executing member's advisor; absent when the client sent none. |
start | RoutedStart | Present 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.
| Field | Type | Description |
|---|---|---|
admitted | Admitted | A 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. |
columns | Columns | The result's column names, before its first rows. |
rows | bytes | A batch of rows, each a list of values in the engine's encoding. |
end | RoutedStats | The statistics that end the answer. |
error | bytes | The 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.
| Field | Type | Description |
|---|---|---|
events | RoutedStatementEvent[] | — |
RoutedStats
What a finished statement reports.
| Field | Type | Description |
|---|---|---|
nodes_created | int64 | — |
nodes_deleted | int64 | — |
edges_created | int64 | — |
edges_deleted | int64 | — |
properties_set | int64 | — |
applied_index | uint64 | Log index the statement's own commit was applied at; zero for none. |
commit_ts | uint64 | Timestamp the statement's own commit landed at; zero for none. |
read_index | uint64 | Log index the read was served at on the executing member. |
read_as_of_ts | uint64 | What a read on a read-only member is as of; zero otherwise. |
read_ts | uint64 | The timestamp the statement read at: every commit at or below it that its view held; zero for none. |
served_by_leader | bool | Whether 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.
| Field | Type | Description |
|---|---|---|
acks | uint32 | Members that must hold the write, the leader included, when majority is false; zero answers without waiting for any. |
majority | bool | A majority of the group must hold the write; acks is then unused. |
journal | uint32 | The state each counted member holds the write in, numbered as coordinode.v1.replication.Journal (1 journal, 2 cache, 3 memory). |
timeout_ms | uint32 | Milliseconds 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.
| Field | Type | Description |
|---|---|---|
file | string | Source file path as the client knows it. |
line | uint32 | Line number in that file, starting at 1. |
function | string | Enclosing 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.
| Value | Number | Description |
|---|---|---|
ROUTED_OPERATION_STATE_UNSPECIFIED | 0 | — |
ROUTED_OPERATION_STATE_COMMITTED | 1 | An attempt of it committed. |
ROUTED_OPERATION_STATE_ABORTED | 2 | It is proven never to take effect. |
ROUTED_OPERATION_STATE_UNKNOWN | 3 | Nothing is recorded of it. |
ROUTED_OPERATION_STATE_RETIRED | 4 | Its record is released. |
