Repository navigation
Compatibility with the Citus extension #619
|
I’m using the Citus extension for a sharded and distributed PG database setup. I wonder if pg-trickle could be used in my setup? With Citus there’s a coordinator node and a number of worker nodes. DDL is done at the coordinator and in my setup, I also do all DML from the coordinator (which in turn will fan out to the worker nodes). Do you think that be possible to accomplish? Note: Shard table placement in Citus is not always stable. A shard table could be moved from one node to another under certain conditions. |
Replies: 5 comments 10 replies
|
Hi @erikmata — thanks for the careful question, and for spelling out your constraints (no automatic failover, no rebalancing, stable shard placement). That makes the answer much more concrete. Short answer: yes, this is doable, and the architecture you sketched (publications + slots on the workers, consumed from the coordinator) is exactly the direction we're taking. Today it isn't supported out of the box, but most of the building blocks already exist in pg_trickle and the gap is well-scoped. We've just refreshed the design plan against the current codebase — it's tracked at What works today on a Citus cluster
What doesn't work today
How we're planning to fix it (matches your intuition)Two recent changes in pg_trickle make the Citus path much smaller than it would have been a few months ago:
The plan, in one paragraph: detect each source's Citus placement at Your stable-placement constraint is a real simplification — the v1 plan explicitly rules out automatic-rebalance support, because a moved shard invalidates its slot. We document that and emit a hard error if What you can do right nowIf your STs are derived from a small number of tables and you can live with one of these workarounds while the integration lands, you have a few options today:
Tracking & timingI won't quote a date, but the foundational pieces (stable naming, per-source frontier cleanup) ship in the next minor and produce benefits even on single-node. The Citus-specific work (per-worker slot CDC, distributed ST apply path) lands in the follow-up minor. The plan doc above lists the phases, file impact, and risks if you want to follow along or comment on any of the design choices — particularly P3.1 ( Two questions back to you that would directly inform the design:
Thanks again for the detailed write-up — it lined up almost exactly with what we'd been sketching internally, which is a good sign we're heading the right way. |
|
Quick update on where things stand — the design work from the discussion thread has now been committed to the roadmap. We've added two dedicated milestones in PR #645: v0.32.0 — Citus: Stable Naming & Per-Source Frontier FoundationThis is the additive groundwork that lands before the Citus-specific features, and it benefits all users: Stable object naming. Today pg_trickle names every internal object — change buffers, trigger functions, WAL slot names, frontier keys — after the PostgreSQL OID of the source table. OIDs are local integers: different on every Citus worker, and they change across Citus detection module. A new Per-source frontier correctness. The frontier (tracking which changes have been consumed) is rekeyed from the table OID to the stable name. Cross-source global LSN comparisons are audited and removed — a correctness fix that matters for multi-source stream tables even without Citus. This release is intentionally sequenced early in the roadmap — before v0.32.0 (reactive subscriptions) and v0.33.0 (temporal IVM) — so every new object those features create is born with the new naming scheme. That keeps the migration footprint small when v0.35.0 ships. v0.35.0 — Citus: Distributed Source CDCThis is the full integration your question was asking about: Per-worker WAL slot CDC (Phase 3). When Distributed stream-table storage (Phase 4). Cross-node coordination (Phase 5). Advisory locks are node-local, so a new Shard rebalance. Out of scope for v0.35.0 — matching your constraint. If Test suite (Phase 6). A dedicated Citus E2E harness: Your two questions from the original replyREPLICA IDENTITY — Source size / placement threshold — the default threshold for auto-selecting Full technical specs: roadmap/v0.32.0.md-full.md · roadmap/v0.35.0.md-full.md Design plan: plans/ecosystem/PLAN_CITUS.md |
|
Thanks for the quick response. My system dynamically constructs quite complex queries for ELT and analytics. The queries are composed of a chain of SQL-withs, which would easily be replaceable with a chain of stream tables instead. I expect some stream tables in the lower layer (earlier in the chain) to have up to billions of rows. So, being able to have distributed stream tables would be very beneficial. All the source tables are distributed and I have no reference tables. All source tables have primary key, which are deterministical and never change, so both REPLICA IDENTITY DEFAULT or FULL would work for my use case. Hope this helps. |
|
Update: full Citus support shipped across v0.32.0 → v0.34.0 The three releases that deliver what you asked about have all shipped. Here's a summary, followed by the slot-sizing numbers for your specific topology. What landedv0.32.0 — Stable Naming & Per-Source Frontier Foundation All internal pg_trickle objects (change buffers, trigger functions, WAL slot names, publication names) are now keyed by a stable 16-char hex string derived from v0.33.0 — Distributed Source CDC & Distributed Stream Table Output This is the core of what you described:
v0.34.0 — Automated Scheduler & Shard Rebalance Auto-Recovery The scheduler is now fully Citus-aware — no manual wiring required:
Slot sizing for your topology (1 coordinator + 9 workers)
As noted earlier, shard count does not enter this formula — pg_trickle creates one slot per worker per source regardless of how many shards that worker holds for that source. Adjusting shard count (your scenario A: rebalance before creating stream tables) leaves slot count unchanged. Your plan to rebalance before creating stream tables is the cleanest path. v0.34.0's auto-recovery is a safety net for the "topology changed unexpectedly" case: rather than silently producing wrong results, the scheduler detects the mismatch, drops stale slots, reprovisions, and queues a full refresh. No committed changes are lost. Integration guideFull prerequisites, step-by-step setup, the Let us know how it goes once you've had a chance to try it — your topology (9 workers, ~500 distributed sources, chains of SQL-WITH → stream tables) is exactly the workload the implementation was validated against. |
|
Thanks. I’ll keep it in mind
tors 30 apr. 2026 kl. 13:52 skrev Geir O. Grønmo ***@***.***>:
… Be aware that there is a breaking change coming in v0.43.0. See
https://github.com/grove/pg-trickle/blob/main/roadmap/v0.43.0.md#di-change-buffer-schema-refactor-breaking
—
Reply to this email directly, view it on GitHub
<#619 (reply in thread)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFJY7ZQWCSBBIYKEQYUKT7L4YM46BAVCNFSM6AAAAACYBN7QBGVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTMNZWHA4TGOI>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Hi @erikmata — thanks for the careful question, and for spelling out your constraints (no automatic failover, no rebalancing, stable shard placement). That makes the answer much more concrete.
Short answer: yes, this is doable, and the architecture you sketched (publications + slots on the workers, consumed from the coordinator) is exactly the direction we're taking. Today it isn't supported out of the box, but most of the building blocks already exist in pg_trickle and the gap is well-scoped. We've just refreshed the design plan against the current codebase — it's tracked at
plans/ecosystem/PLAN_CITUS.md, and the user-facing summary is below.What works today on a Citus cluster