#26510·risingwave

postgres-cdc: Rust external table reader defaults `ssl.mode` to `disabled` while Debezium defaults to `prefer`, with no recovery path and a misleading error

Author: yuhao-suCreated Jul 30, 2026Updated Sep 29, 2026
Labelstype/bugno-issue-activity

Summary

For postgres-cdc, the Java/Debezium half and the Rust external table reader half disagree on the default value of the same user-facing ssl.mode option:

half source of default effective default
Debezium / Java (source streaming) java/connector-node/risingwave-connector-service/src/main/resources/postgres.properties:13 — database.sslmode=${ssl.mode:-prefer} prefer (negotiates TLS)
Rust ExternalTableReader (StreamCdcScan) src/connector/src/source/cdc/external/mod.rs:314 — postgres_ssl_mode_default() disabled (plaintext)

So when a user creates a postgres-cdc source without specifying ssl.mode against an upstream that mandates TLS (e.g. Neon, and generally most managed Postgres offerings), the result is a confusing split-brain: the source streams normally, while the CDC table's external table reader can never connect.

Three further problems make this much worse than it needs to be: the reader is created even when it is not needed, there is no way to fix an existing table, and the reported error points at the wrong thing entirely.

Observed on v3.0.1; the relevant code is unchanged on v3.0.2 / main except where noted.


1. Inconsistent ssl.mode default between the two halves

rust
// src/connector/src/source/cdc/external/mod.rs:314
fn postgres_ssl_mode_default() -> SslMode {
    // NOTE(StrikeW): Default to `disabled` for backward compatibility
    SslMode::Disabled
}

Against a TLS-mandating upstream, the plaintext startup packet is rejected. Reproduced directly from inside a compute pod against such an endpoint:

$ # plaintext StartupMessage, i.e. what ssl.mode=disabled does
  → E ... SERROR C28000 M"connection is insecure (try using `sslmode=require`)"

$ # SSLRequest + TLS handshake with SNI, i.e. what ssl.mode=required does
  → 'S', TLSv1.3 handshake OK

Note this is postgres-specific — mysql.properties uses ${ssl.mode:-disabled}, which is consistent with the Rust side. Only the postgres pair is mismatched.

Suggestion: align the Rust default with the Debezium default (Preferred). Preferred already disables certificate verification in create_pg_client, so it should not break plaintext upstreams, which makes it a fairly safe change for the stated backward-compatibility concern.

2. The external table reader is created even when disable_backfill is set

In CdcBackfillExecutor::execute_inner, need_backfill is computed:

rust
// src/stream/src/executor/backfill/cdc/cdc_backfill.rs:280
let need_backfill = !self.options.disable_backfill && !state.is_finished;

…but the reader-creation future is then built unconditionally, ignoring it:

rust
// src/stream/src/executor/backfill/cdc/cdc_backfill.rs:289-305
let mut table_reader: Option<ExternalTableReaderImpl> = None;
let external_table = self.external_table.clone();
let mut future = Box::pin(async move {
    let backoff = get_infinite_backoff_strategy();
    tokio_retry::Retry::spawn(backoff, || async {
        match external_table.create_table_reader().await {
            Ok(reader) => Ok(reader),
            Err(e) => {
                tracing::warn!(error = %e.as_report(), "failed to create cdc table reader, retrying...");
                Err(e)
            }
        }
    })
    .instrument(tracing::info_span!("create_cdc_table_reader_with_retry"))
    .await
    .expect("Retry create cdc table reader until success.")
});

A table created WITH (snapshot = 'false') has no snapshot to read, so it never needs this reader — yet it retries forever on an infinite backoff.

To be fair on severity: this is not fatal. Because need_backfill == false, build_reader_and_poll_upstream keeps forwarding upstream chunks and barriers normally, so data still flows correctly and the epoch still advances. The executor just never leaves that loop and emits a warning every ~10s indefinitely. But it burns a retry loop and produces continuous log noise for work that is provably unnecessary.

Suggestion: skip reader creation entirely when self.options.disable_backfill is true.

3. There is no recovery path for an existing CDC table

Once a CDC table exists with the wrong ssl.mode, neither SQL nor risectl can fix it:

(a) ssl.mode is not alterable on the fly. In src/connector/src/allow_alter_on_fly_fields.rs, PostgresCdcProperties permits only:

v3.0.1: cdc.source.wait.streaming.start.timeout, debezium.max.queue.size,
        debezium.queue.memory.ratio, password
v3.0.2: + debezium.heartbeat.interval.ms, hostname, port

ssl.mode is absent in both, so ALTER SOURCE ... CONNECTOR WITH (ssl.mode = 'required') is rejected.

(b) Even bypassing that, the change does not reach the CDC table. risectl meta alter-source-properties-safe skips the allowlist (update_source_props_by_source_id(..., skip_alter_on_fly_check = true)), but the propagation step only rewrites Source nodes:

rust
// src/meta/src/controller/streaming_job.rs:2511
update_connector_props_fragments(
    &txn,
    to_check_job_ids,
    FragmentTypeFlag::Source,              // <-- StreamCdcScan fragments are not matched
    |node, found| {
        if let PbNodeBody::Source(node) = node
            && let Some(source_inner) = &mut node.source_inner
        {
            source_inner.with_properties = options_with_secret.as_plaintext().clone();
            source_inner.secret_refs = options_with_secret.as_secret().clone();
            *found = true;
        }
    },
    is_shared_source,
)

The failing reader reads StreamCdcScan.cdc_table_desc.connect_properties — a copy snapshotted at CREATE TABLE time. Every site in src/meta that touches PbNodeBody::StreamCdcScan only mutates rate_limit; none updates connect_properties.

Net effect: the only way to correct ssl.mode on an existing CDC table is to drop and recreate the table, which for a large backfilled table (and any dependent sinks) is a very expensive remedy for a one-line config default.

Suggestion: add ssl.mode (and ssl.root.cert) to the postgres-cdc allowlist, and extend the propagation to also rewrite StreamCdcScan.cdc_table_desc.connect_properties for dependent CDC tables.

4. The reported error points at the wrong thing

This is what made the above expensive to diagnose. The only error surfaced was:

json
{"level":"WARN",
 "message":"failed to create cdc table reader, retrying...",
 "error":"error connecting to server: Network is unreachable (os error 101)"}

ENETUNREACH is a pure red herring here. Two things combine:

(a) connect_host discards all but the last error. In tokio-postgres (connect.rs, inherited from upstream sfackler/rust-postgres via the madsim-rs/rust-postgres patch):

rust
let mut last_err = None;
for addr in addrs {
    match connect_once(Addr::Tcp(addr.ip()), hostname.as_deref(), port, tls, config).await {
        Ok(stream) => return Ok(stream),
        Err(e) => { last_err = Some(e); continue; }   // earlier errors dropped
    };
}
Err(last_err.unwrap_or_else(|| /* could not resolve any addresses */))

The retry-every-address logic is correct; only the reporting is lossy.

(b) Address ordering makes it systematically pick the least useful error. The upstream endpoint publishes both A and AAAA records. On a pod with no global IPv6 address and no IPv6 default route, glibc's RFC 6724 sorting puts IPv4 first and IPv6 last:

IPv4  → rejected by the server: 28000 "connection is insecure"   <-- the real cause
IPv4  → same
IPv4  → same
IPv6  → ENETUNREACH (no IPv6 route on this pod, true for any IPv6 destination)
IPv6  → ENETUNREACH
IPv6  → ENETUNREACH   <-- this one becomes last_err and is the only one reported

So the structural, content-free failure always wins the last_err slot and the actionable, config-level failure is always discarded.

(c) The log line does not say what it is connecting to. PostgresExternalTableReader::new has the full ExternalTableConfig in hand but logs none of it:

rust
// src/connector/src/source/cdc/external/postgres.rs:237
tracing::info!(
    ?rw_schema,
    ?pk_indices,
    "create postgres external table reader"
);

No host, no port, no database, and crucially no ssl_mode. Combined with (a) and (b), an operator sees a network-flavoured error, with no indication of which endpoint or which TLS setting was used — and the true root cause (ssl_mode = Disabled) appears nowhere in any log.

Suggestions, in descending value-for-effort:

  1. Log host, port, database and ssl_mode in PostgresExternalTableReader::new. This alone turns this class of problem into a few-seconds diagnosis, and needs no upstream change.
  2. Include the same connection context in the failed to create cdc table reader warning.
  3. Longer term / upstream rust-postgres: aggregate per-address errors rather than keeping only the last, or at minimum prefer a protocol/TLS-layer error over a raw ENETUNREACH/EHOSTUNREACH.

Reproduction

  1. Create a postgres-cdc source against any Postgres that requires TLS, omitting ssl.mode.
  2. Create a CDC table on it with WITH (snapshot = 'false').
  3. The Debezium source streams normally (it defaulted to prefer), but the table's StreamCdcScan logs failed to create cdc table reader, retrying... every ~10s forever.
  4. If the endpoint also publishes AAAA records and the pod has no IPv6 route, the reported error is Network is unreachable (os error 101) rather than the actual TLS rejection.
  5. Attempting ALTER SOURCE <src> CONNECTOR WITH (ssl.mode = 'required') is rejected by the alter-on-fly allowlist; going through risectl updates the source catalog but leaves the table's reader unchanged.

Environment

  • RisingWave v3.0.1 (code paths re-checked against v3.0.2 / main; only the allowlist in §3 differs, and ssl.mode is still absent there)
  • Upstream: managed Postgres requiring TLS, publishing both A and AAAA records
  • Compute pod: IPv4-only (no global IPv6 address, no IPv6 default route)

Source: risingwavelabs/risingwave