aiondb-fragment-transport

Remote fragment execution transport. Provides client and server components that ship PhysicalPlan fragments between cluster nodes over framed TCP, with shared-secret authentication and optional rustls-based TLS. The wire protocol is a length-prefixed JSON envelope; the current PROTOCOL_VERSION is 1 and payloads are capped at 64 MiB.

cargo

[dependencies]
aiondb-fragment-transport = { path = "../aiondb-fragment-transport" }

modules

modulepurpose
protocolwire types and codec: FragmentRequest, FragmentResponse, CancelRequest, FragmentSnapshot, TransportEnvelope, TransportPayload, version and message-type constants.
authAuthToken: shared-secret token, redacted in Debug.
tlsTlsClientConfig, TlsServerConfig: rustls connector and acceptor builders.
clientFragmentClient, ConnectionPool: pooled async client.
serverFragmentServer, FragmentExecutor: TCP listener executing fragments locally.

wire protocol

msg_type (u8) | payload_len (u32 LE) | payload (JSON)
message typebyte
MSG_EXECUTE_FRAGMENT0x01
MSG_CANCEL_FRAGMENT0x02
MSG_FRAGMENT_RESULT0x81
MSG_FRAGMENT_ERROR0x82
MSG_CANCEL_ACK0x83

Servers accept envelopes whose version is in MIN_PROTOCOL_VERSION..=PROTOCOL_VERSION (currently both are 1). The coordinator embeds a random cancel_key in FragmentRequest; subsequent CancelRequest messages must replay it for the cancel to be honoured.

key types

typerole
AuthTokenshared-secret authentication token.
FragmentRequestexecute-fragment envelope: plan, txn id, isolation, resource caps, optional snapshot, optional shard id, deadline, cancel key.
FragmentSnapshotserialised MVCC snapshot (xmin, xmax, active).
CancelRequestcancel envelope carrying request_id and cancel_key.
FragmentResponseSuccess, Error, or CancelAck.
TransportEnvelope, TransportPayloadtop-level wrapper types.
TlsClientConfig, TlsServerConfigPEM file paths for rustls.
ConnectionPoolper-host pool of idle TLS or plaintext connections.
FragmentClienthigh-level client for sending requests and cancels.
FragmentServer, FragmentExecutoraccept loop and per-request executor trait.

status

The transport is in active development. The server enforces protocol-version bounds, payload-size caps, cancel-authorization keys, and a 30-second drain on shutdown. TLS is optional and configured via PEM files; when absent the connection runs over plain TCP and authentication is the only barrier.

example

use aiondb_fragment_transport::{AuthToken, FragmentRequest};

let token = AuthToken::new("shared-secret-from-config");
token.require_non_empty().expect("auth token must be set");

// Building a real FragmentRequest requires a PhysicalPlan from
// aiondb-plan; clients normally construct these via the higher-level
// query coordinator rather than by hand. The struct fields are:
//
//   request_id, plan, txn_id, isolation, max_result_rows,
//   max_result_bytes, max_memory_bytes, max_temp_bytes,
//   snapshot, deadline_epoch_ms, shard_id, cancel_key
let _ = std::any::type_name::<FragmentRequest>();