Repository navigation
Description
Summary
All sink consumers on a Postgres source share one replication slot. If one sink cannot register its SlotMessageStore, restart_wal_cursor!/1 raises an InvariantError, which kills SlotProcessorServer → SlotProducer → the entire SlotSupervisor. CDC stops for every sink on that slot, not just the failing one.
The failure is self-sustaining: killing the process aborts the very monitoring that would satisfy the invariant, so the restarted tree hits the same assertion. A supervisor restart cannot converge.
Version: v0.14.6, self-hosted on Kubernetes with an external Postgres.
Impact
A single-sink problem became a multi-hour outage of all CDC on that slot. Six sinks were configured, five were entirely healthy, and all six stopped.
The pod stayed 1/1 Ready throughout — liveness and readiness probes do not observe the replication supervisor — so nothing alerted on it.
The loop
Sink consumer ids and the slot id are redacted below as <sink-N> and <slot>.
Sink consumer IDs do not match monitored sink consumer IDs.
Sink consumers: ["<sink-1>", "<sink-2>", "<sink-3>",
"<sink-4>", "<sink-5>", "<sink-6>"].
Monitored: []
(sequin 0.1.0) lib/sequin/runtime/slot_processor_server.ex:744:
Sequin.Runtime.SlotProcessorServer.restart_wal_cursor!/1
(sequin 0.1.0) lib/sequin/runtime/slot_processor_server.ex:242:
Sequin.Runtime.SlotProcessorServer.handle_call/3
Last message (from #PID<...>): :restart_wal_cursor
Six sink consumers exist; Monitored is empty. Cascading from it:
GenServer {:replication, {Sequin.Runtime.SlotProducer, "<slot>"}} terminating
** (stop) exited in: GenServer.call({:via, :syn, {:replication,
{Sequin.Runtime.SlotProcessorServer, "<slot>"}}}, :restart_wal_cursor, 5000)
and the supervisor failing to re-establish monitoring:
[Runtime.Supervisor] Failed to start SlotSupervisor:
{:shutdown, {GenServer, :call, [{:via, :syn, {:replication,
{Sequin.Runtime.SlotProcessorServer, "<slot>"}}},
{:monitor_message_store, %Sequin.Consumers.SinkConsumer{
id: "<sink-6>", max_memory_mb: 128,
load_shedding_policy: :pause_on_full, status: :active, ...}}, 120000]}}
Note the failure reason is :shutdown, not :timeout — the target is already going down when the monitor call arrives. That is the race: the invariant fires before monitoring can complete, and enforcing it destroys the process that would have completed it.
Only one sink ever appeared in these monitor failures — 14 of 14 occurrences named the same one. The other five were collateral.
Why that one sink could not register
Its store could not load its persisted messages inside the hardcoded 5000 ms budget:
Failed to load messages from store for consumer <sink-6>:
[SlotMessageStore] call timed out after 5000ms
lib/sequin/runtime/slot_message_store.ex:216:
SlotMessageStore.unpersisted_table_reader_batch_ids/1
That sink streams a table of pgvector embeddings — 1536 dimensions, roughly 6 KB per row — and had a backlog of about 2,000 messages persisted from a period when its Kafka destination was unavailable.
This is closely related to #2128 (put_persisted_messages bypassing max_memory_mb on startup) and #2132 (discard not persisting, so the backlog survives restarts). Note the reporter in #2128 also had max_memory_mb=128, which is the per-sink default.
Reproduction
- Configure several Kafka sinks on one Postgres source, i.e. sharing one slot.
- On one of them, accumulate a large persisted backlog by making the destination unavailable — a stopped broker is enough. Wide rows make it easier to hit.
- Restore the destination and restart Sequin.
- That one sink's store cannot rehydrate within 5000 ms →
Monitored: []→ every sink on the slot stops.
Observed vs expected
| Observed | One unregisterable sink halts CDC for all sinks on the slot, permanently, across restarts |
| Expected | A sink that cannot start is isolated. It reports unhealthy; the other sinks keep delivering |
Notes
Three concerns, roughly in order of value:
- Isolation. A per-sink failure should not be a per-slot failure. That is the core bug.
- The invariant is unsatisfiable under its own enforcement. If
Monitoredcan legitimately be empty mid-startup, raising is wrong; if it cannot, the raise must not destroy the monitoring path. Either way, restarting cannot currently converge. restart_wal_cursoris a 5000 msGenServer.callwhile the store may be doing unbounded rehydration work. The timeout and the work are unrelated to each other.
Escape hatch, for anyone hitting this now
Nothing was recoverable from the UI — list, discard, load and monitor all time out against the jammed store, so the controls that would fix it cannot run. What worked: delete the offending sink, restart, and let config re-create it with a clean store. Cancelling the in-flight backfill first was not sufficient, and neither were two full pod restarts.
Activity
dosubot commentedon Sep 7, 2026
Hi @o6uoq! I'm Dosu and I'm helping the Sequin team.
Your diagnosis is accurate — I traced the same mechanism through the code. Here's what I found confirming each piece:
The invariant and crash path.
verify_monitor_refs/1checks that every non-disabled sink consumer ID (excluding those inserted in the last 10 minutes) appears instate.message_store_refs. When a consumer is missing, it returns{:error, Error.invariant(...)}, andrestart_wal_cursor!/1raises that error. Sincehandle_call(:restart_wal_cursor, ...)callsrestart_wal_cursor!directly, the raise propagates through theGenServer.calland killsSlotProcessorServer.Why
Monitoredis empty.start_children/2starts all message stores first, then the slot processor, and only after both callsmonitor_message_storefor each consumer. Store startup runsstream_messages_into_state/1synchronously inhandle_continue(:init, ...)— the store cannot accept calls (includingset_monitor_ref) until this completes. A slow rehydration (your 2,258-row pgvector backlog) blocks the store from registering, somessage_store_refsstays empty for that consumer.Why recovery cannot converge.
SlotProducercallsupdate_restart_wal_cursoron a 10-second timer, which invokesrestart_wal_cursor_fn→SlotProcessorServer.restart_wal_cursor/1. The invariant fires before the slow store finishes rehydrating and gets monitored. The raise killsSlotProcessorServer, and the supervisor restart races a fresh startup of the same slow store — exactly the:shutdown(not:timeout) you observed, because the target process is already going down when themonitor_message_storecall arrives.Existing coverage. #2141 shows the same
monitor_message_store/restart_wal_cursorshutdown trace from another user, but is about a different root cause (stale replication connection). #2128 and #2132 are about persisted-message rehydration bypassingmax_memory_mb. None of them propose isolating per-sink startup failure from the shared invariant check, so this appears to be a distinct report.One detail worth noting:
verify_monitor_refsdoes have a grace period — it filters out consumers inserted in the last 10 minutes — but that only covers newly created consumers, not existing consumers whose stores are slow to start. Extending this grace to cover "not yet monitored" stores (or converting theraiseto a log + skip for unmonitored consumers) would address the convergence issue.To reply, just mention @dosu.
Share context across your team and agents. Try Dosu.