Skip to content

moonlink 0.3.0: WAL-Free Iceberg Recovery & Hardened CDC

Moonlink v0.3.0 syncs upstream Mooncake-Labs/moonlink v0.3-dev (dcf999a9), replacing Moonlink’s private WAL with Iceberg-backed replication slot acknowledgement, adding per-table errored isolation, Iceberg file GC, bounded resource controls, and Arrow/Parquet 56.

Moonlink v0.3.0 synchronizes pgsty/moonlink with upstream Mooncake-Labs/moonlink v0.3-dev at commit dcf999a9. It serves as the upstream-aligned 0.3 baseline beneath PGSTY’s hardened engine releases (v0.3.0-pgsty.1 and v0.3.0-pgsty.2).

Baseline Tag vs. PGSTY Patch Releases

v0.3.0 preserves the exact upstream v0.3-dev baseline (dcf999a9). For deployments of pg_mooncake 0.3.3 and pg_mooncake 0.3.4, use Moonlink v0.3.0-pgsty.2, which layers generation-checked mirror lifecycle management, zero-vulnerability storage upgrades (Iceberg 0.11 / Arrow 58.4.2 / SQLx 0.9.1), and durable snapshot acknowledgements on top of this baseline.

Summary of Changes

Area Change
WAL-free Iceberg recovery Removes Moonlink’s private _wal directory entirely. PostgreSQL replication slot confirmed_flush_lsn is now advanced only up to the minimum LSN persisted into Apache Iceberg across healthy mirrors of that source.
Per-table errored isolation Replaces fatal worker panics with persistent per-table error markers under errored_tables/. An out-of-sync mirror rejects queries with its diagnostic reason while healthy mirrors continue replicating uninterrupted.
CDC correctness & schema drift Stores source table OID, column definitions, and partition topology under source_fingerprints/, polling for schema changes, TRUNCATE, inheritance children, unlogged partitions, and enum renames. Enforces strict type/value fidelity and fixes \\N text copy semantics.
Replication recovery & initial copy Returns from create_table only after the initial copy is durably persisted in Iceberg, speeds up initial-copy row conversion, drops publication entries by relation OID, handles full-disk cancellation and mid-create drops safely, and restores a consistent view when streamed transactions abort or end unapplied.
Storage, Iceberg GC & bounds Adds atomic Iceberg metadata writes, automatic garbage collection of superseded Iceberg files (MOONLINK_ICEBERG_GC), bounded LSN wait (MOONLINK_LSN_WAIT_TIMEOUT_SECS, default 30 s), disk-full backoff (30 min / 512 MiB cap), and bounded write amplification, memory slices, and cache budgets.
Scope slimming & RPC stability Removes unused Delta Lake, DataFusion, REST/Glue catalogs, Kafka, OpenTelemetry, GCS, and Postgres metadata store components; upgrades Arrow/Parquet to 56; pins the append-only moonlink_rpc and moonlink_table_metadata wire format with byte-level golden tests (tests/wire_golden.rs).

Architectural Highlights

1. Eliminating the Private WAL

In v0.0.1 (shipped with pg_mooncake 0.3.0), Moonlink maintained its own private _wal log and could acknowledge PostgreSQL’s logical replication slot before changes reached Iceberg. In v0.3.0, Moonlink removes _wal completely:

  • Iceberg-backed slot advancement: compute_confirmed_flush_lsn advances a source database’s replication slot (moonlink_slot_<db>) strictly to the minimum Iceberg-persisted LSN across its healthy mirrors.
  • Bounded WAL retention: Active mirrors persist at least every ~300 seconds (or sooner as rows accumulate); idle mirrors and errored mirrors do not hold back pg_wal.
  • Clean restart recovery: On restart, Moonlink reads moonlink_metadata_store.sqlite, reloads each mirror from its latest Iceberg v3 snapshot (with Roaring deletion vectors), and replays only unpersisted commits from the PostgreSQL replication slot.

2. Per-Table Fault Isolation & Strict CDC Fidelity

  • No cross-table blast radius: Unsupported source DDL (column additions/drops/renames/type changes, REPLICA IDENTITY changes away from FULL, TRUNCATE, INHERITS, dropping/detaching partitions, attaching populated partitions, or ROLLBACK TO SAVEPOINT inside streamed transactions exceeding logical_decoding_work_mem) transitions only the affected mirror into a persisted errored state instead of crashing the background worker.
  • Deterministic row-position indexing: Replaces per-restart random hashing seeds with deterministic lookup indices. On the first startup after upgrading, existing mirrors automatically rebuild their lookup indices once from their data files so updates and deletes on previously flushed rows remain accurate across restarts.
  • Exact type boundaries: Rejects unsupported source types (interval, timetz, multi-dimensional arrays, numeric precision > 38, and unrepresentable values such as numeric NaN/Infinity or infinity dates/timestamps) explicitly instead of silently altering data.

3. Iceberg Garbage Collection & Resource Bounds

  • Automatic Iceberg GC: Deletes superseded metadata files, manifests, deletion vectors, and compacted Parquet data files once no active scan references them and neither the current nor previous version needs them. Set MOONLINK_ICEBERG_GC=dry-run to inspect deletions or MOONLINK_ICEBERG_GC=off to retain historical files.
  • Bounded waits & disk-full protection: Queries waiting on replication LSNs time out after 30 seconds by default (MOONLINK_LSN_WAIT_TIMEOUT_SECS) with a retryable error naming both requested and replicated LSNs. When disk space is exhausted, flushes retry cleanly and cap buffered waiting changes at 30 minutes or 512 MiB across all mirrors to protect the PostgreSQL background worker from OOM termination.

Upgrade & Security Notes

  • Upgrading from v0.0.1 (pg_mooncake 0.3.0): Because v0.3.0 removes _wal, operators migrating existing mirrors from pg_mooncake 0.3.0 must stop source writers, verify mirror parity and flush all changes to Iceberg on the old binaries, and move _wal offline with a full backup before starting any 0.3.x worker.
  • RustSec dependency audit: Removing Delta Lake, DataFusion, Kafka, and OpenTelemetry substantially reduced the dependency tree; the November 22, 2026 RustSec snapshot still matched 22 vulnerabilities in the full v0.3.0 lockfile (primarily transitive dependencies under iceberg 0.7, opendal 0.54, parquet 56, and sqlx-sqlite 0.8). All of those findings were eliminated in Moonlink v0.3.0-pgsty.1.

See the Moonlink Engine Guide and Architecture Overview for full operational details.

Table reader