Skip to content

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.

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 ps and 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.

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:

  1. Connector sends Hello {connector, version, protocol}. Protocol mismatch fails.
  2. Runner sends one JSON line: the Request.
  3. Connector answers per op:
    • test, discover, splits, finalize → Result {value}
    • schema → S then Done
    • read → S, any number of B, then Done {rows, consumed}
    • write → runner streams S, B…, E; connector replies Done {rows}
  4. At any point: Progress {rows}, Log {message}, or Error {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.

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:

  1. If the extract has a split, the runner asks the connector for splits (key_range → split_column + split_count; native → split_count = max).
  2. Splits are read in parallel (4 processes by default), each written to a local Parquet file in the run’s scratch directory.
  3. 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.

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 query is wrapped as a subquery and must be a single statement.
  • key_range splits come from MIN/MAX of 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: sslmode semantics as in libpq (prefer falls back to plain). Writes use COPY; replace truncates in the same transaction, so readers never see an empty table; upsert loads a temp table and uses ON CONFLICT on the key. Creates the table when missing (create_table, default on).
  • mysql: ssl_mode as 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_size documents by _id, so schema and read agree. 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. query is a JSON filter (object) or an aggregation pipeline (array). Splits use $bucketAuto on 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.
  • 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.