04 · Connectors & protocol
Status: Implemented (T5 schemas, T8 protocol and connectors) · Owner: Platform
Connectors move data between Flux and external systems. This document covers the
runner↔connector protocol, isolation, how the engine uses connectors for reads and writes,
and per-connector behaviour. Connection field schemas are generated into the
connector reference from
control-plane/src/flux_cp/connections/types.py.
Process model
Section titled “Process model”Every operation spawns one connector process and ends when it exits
(ADR-0003). The runner (flux_proto::client):
- starts the executable with an empty environment (only
PATH,HOME,TMPDIR), so runner secrets never leak into a connector; - sends the request, including decrypted credentials, on stdin only (never argv or
env, which show up in
psand crash dumps); - kills the process when the handle drops (
kill_on_drop), so a cancelled run leaves nothing behind; - keeps the last 40 stderr lines for error reports.
Fail loud. A crash, a signal, a non-zero exit, a protocol violation, a schema change
mid-read, or a missing handshake is always an error naming the connector. A read only
ends successfully after the connector sent Done and exited with status 0, so a crash
can never look like a short result.
Wire protocol
Section titled “Wire protocol”stdio, not a Unix socket (the original plan): one process per operation means stdin/stdout already give a private, ordered, back-pressured channel with no socket paths, permissions or cleanup. Back-pressure is the OS pipe buffer: a connector blocks on write when the runner stops reading.
Connector → runner frames are tag: u8 | len: u32 BE | payload:
| Tag | Payload |
|---|---|
J |
JSON message (below) |
S |
Arrow IPC schema |
B |
Arrow IPC stream with exactly one record batch (ZSTD-compressed buffers) |
E |
End of input (runner → connector, writes only) |
Sequence:
- Connector sends
Hello {connector, version, protocol}. Protocol mismatch fails. - Runner sends one JSON line: the
Request. - Connector answers per op:
test,discover,splits,finalize→Result {value}schema→SthenDoneread→S, any number ofB, thenDone {rows, consumed}write→ runner streamsS,B…,E; connector repliesDone {rows}
- At any point:
Progress {rows},Log {message}, orError {kind, message}.
Error kinds: config, auth, network, not_found, data, unsupported, internal.
They are shown to users as-is; only internal errors carry the stderr tail.
Request fields: op, connection {type, values}, object or query, columns,
options, limit (samples), split / split_count / split_column,
watermark {column, after}, write {mode, key}, batch_rows.
How the engine uses connectors
Section titled “How the engine uses connectors”flux_exec::connect implements the engine’s Sources and Sinks traits
(design 02).
Resolution. A ConnectorResolver maps an artifact name to an executable. In the
cluster this is the Forge-verified bundle (design 05); in development
DirResolver uses engine/target/debug. ADBC types share the flux-connector-adbc host.
Runs spool once. For a run, each extract node is read exactly once:
- If the extract has a
split, the runner asks the connector forsplits(key_range→split_column+split_count;native→split_count=max). - Splits are read in parallel (4 processes by default), each written to a local Parquet file in the run’s scratch directory.
- The plan scans the spool.
Runtime checks (validate ratios, empty checks) and every target then see identical
rows, and a source is never queried twice in one run. The cost is local disk equal to
the compressed extract size, which is sized with the compute profile
(design 03).
Previews sample. Previews use one process with limit, held in memory.
Incremental extracts pass watermark {column, after}: after is the last committed
value for the node (or watermark.initial on the first run). Connectors compare in the
source’s own type and order by the watermark column.
Shards. In sharded runs every shard reads the source and keeps its rows with the
engine-side flux_shard hash (design 03); connectors don’t push
the hash down. broadcast extracts skip the filter.
Object-store defaults. file-drop and sqlite connections may leave the endpoint
empty to use the cluster object store. The runner fills in its endpoint and credentials
only for an allow-list of drop buckets, so a connection can’t borrow them to read the
lake or Forge buckets.
Writes. connection targets stream the target frame into the connector’s write.
External systems are not part of the lake’s two-phase commit: they are written while the
run stages, so a run that fails later may already have written them. Use upsert (or an
idempotent endpoint) for targets that must tolerate retries.
Finalize. Reads report what they consumed (Done.consumed, e.g. file paths). After the
orchestrator commits the run, finalize gives each connector that list, so drops are
only moved or deleted once their data is committed. A finalize failure is reported loudly;
the commit stands, and the files stay where they were, so nothing is lost.
Built-in connectors
Section titled “Built-in connectors”| Connector | Types | Source | Target | Integration tests (required in CI) |
|---|---|---|---|---|
flux-connector-postgres |
postgres (+ Aurora, AlloyDB, Timescale, Redshift) | yes | yes | yes |
flux-connector-mysql |
mysql, mariadb | yes | – | yes |
flux-connector-mssql |
mssql, Azure SQL | yes | – | no (build + unit only) |
flux-connector-sqlite |
sqlite file in object storage | yes | – | yes |
flux-connector-mongodb |
mongodb, Atlas | yes | – | yes |
flux-connector-adbc |
oracle, snowflake, databricks, bigquery | yes | – | host tested with real ADBC PostgreSQL/SQLite drivers; vendor drivers not tested |
flux-connector-http |
http | yes | yes | yes |
flux-connector-files |
file-drop (S3), sftp | yes | yes | S3 yes; SFTP no |
ODBC is published in the reference as planned; saving an odbc connection is rejected
until a connector ships.
Common rules for SQL connectors (flux-sqlkit):
- Identifiers are quoted per dialect; values are bound parameters, or escaped literals cast to the column type for the ADBC warehouses (parameter support differs per driver).
- A user
queryis wrapped as a subquery and must be a single statement. key_rangesplits come fromMIN/MAXof the column; the last range is open-ended and also takes NULL keys, so every row lands in exactly one split.- Types are normalised: integers → Int64, floats → Float64, exact decimals → Decimal128 with the source precision, timestamps → microseconds (UTC when zoned). Types without a mapping are read as text rather than dropped.
Per-connector notes:
- postgres:
sslmodesemantics as in libpq (preferfalls back to plain). Writes useCOPY;replacetruncates in the same transaction, so readers never see an empty table;upsertloads a temp table and usesON CONFLICTon the key. Creates the table when missing (create_table, default on). - mysql:
ssl_modeas in the MySQL client.TINYINT(1)→ boolean,BIGINT UNSIGNED→ Decimal(20,0), zero dates → null. - mssql: TDS 7.3 over rustls; named instances via SQL Browser. Tested only by building and unit tests, because there’s no SQL Server available locally or in CI.
- sqlite: downloads the file to scratch, then reads it read-only.
- mongodb: top-level fields become columns; nested documents and arrays become
relaxed Extended JSON text. The schema comes from the first
schema_sample_sizedocuments by_id, soschemaandreadagree. A later value that doesn’t fit the sampled type fails the read with a hint to raise the sample size or cast in a pipeline, rather than dropping or coercing it.queryis a JSON filter (object) or an aggregation pipeline (array). Splits use$bucketAutoon the split column; documents whose key is missing or another type go to the first split. - adbc: one host binary; each Forge bundle ships it with exactly one driver in
drivers/, and the host only loads from there. Oracle wallets aren’t supported yet (a connection with one fails). Nested values become JSON text. - http: see the HTTP connector reference; SSRF protection pins DNS results, refuses private networks unless allowed, and never follows redirects or pagination to another host.
- files: one split per file; CSV, JSON, JSONL, Parquet, Excel. Every file must fit the first file’s columns. SFTP pins the host key fingerprint. Writes go to a temporary name and are renamed when complete.
Open questions
Section titled “Open questions”- Credential refresh for very long reads (OAuth2 tokens expiring mid-read).
- Pushing the shard hash down to SQL sources to avoid reading full tables per shard.
- An ODBC connector for DB2/Teradata/Informix.
See the architecture overview.