Skip to content

fix: a sink that is down stalls the stream and never parks a change - #22

Merged
emoss08 merged 1 commit into
mainfrom
search-outage-never-parks
Nov 18, 2026
Merged

emoss08 merged 1 commit into
mainfrom
search-outage-never-parks

Conversation

@emoss08

@emoss08 emoss08 commented Nov 18, 2026

Copy link
Copy Markdown
Owner

What changed and why

A sink being restarted (Meilisearch, say) could lose changes to the dead-letter queue. An
unreachable sink was treated as a passing error; the dead-letter layer counted each failed
cycle against the batch's first event and parked it at CDC_DLQ_THRESHOLD (3), before the
circuit breaker opened at 5; nothing retried it. The record then stayed missing or stale in
search until it changed again.

One rule now holds for every sink: a sink that is down stalls the pipeline and loses nothing;
only a change the sink rejects is parked.

  • domain: a sink error is Permanent (the data), Unavailable (the sink) or transient.
    IsUnavailable also recognizes an open circuit, an attempt timeout and transport errors.
  • Each sink classifies its sink-wide failures as Unavailable (Meilisearch no response, 5xx,
    408, 429, 401, 403 and system or auth task errors; webhook 5xx, 408, 429, 401, 403, 404;
    Redis loading, read-only, OOM, cluster or master down, auth, closed pool; NATS disconnected,
    no servers, timeouts, JetStream 5xx).
  • resilience: a failure the sink did not classify is Unavailable when the sink's health check
    fails too, once retries are spent.
  • dlq: an unavailable failure is never counted, split or parked, and isolation stops as soon
    as the sink turns out to be down.
  • services: an unavailable sink holds the batch in process and is retried with backoff (1 s
    to 30 s) until it takes it, without tearing the stream down, so the sinks that took the batch
    are not sent it again.
  • The stall is visible: /readiness is not ready and lists stalled_sinks and
    unhealthy_sinks, /api/stats marks the sink, cdc_sink_stalled{sink}, and a warning when
    the stall starts, once a minute, and when it ends.

Dead letters are not retried automatically. Replaying a parked event can write an older
version of a row over a newer one, and GTC has no safe way today to re-read a row's current
state by key (parked events are stored after transforms, which can drop or mask the key).
POST /dlq/retry is unchanged.

Behaviour to know about

  • /readiness now answers 503 while a sink is down. A liveness probe must stay on /health,
    or a sink outage would get GTC restarted in a loop. The Trenova chart's readiness probe moves
    to /readiness in emoss08/Trenova's worktree-managed-followups branch.
  • The other sinks still wait while one is stalled: there is one slot and one position, so it
    can only be confirmed past changes every sink has.
  • Entries an older GTC parked during past outages are not fixed by this: discard them and run
    POST /backfill.

Checks run

  • go vet ./cmd/... ./internal/... and gofmt: clean.
  • go test -race on every package under cmd and internal: pass.
  • The Postgres integration test TestEndToEnd against a throwaway postgres:18-alpine
    (wal_level=logical) and redis:7-alpine: pass (41 s). Its NATS part was skipped: no NATS
    URL.
  • A Windows build: pass.

To reach an instance

Tag a release so the image publishes (latest is v0.10.0), then bump gtc.image.tag in
deploy/helm/trenova/values.yaml (0.9.1) and dev/compose.yml in emoss08/Trenova.

🤖 Generated with Claude Code

https://claude.ai/code/session_01G7VRX3LAZReXjVdthBP8WJ

A sink being restarted (Meilisearch, say) could lose changes to the
dead-letter queue: an unreachable Meilisearch was a transient error, the DLQ
counted each failed cycle against the batch's first event and parked it at
CDC_DLQ_THRESHOLD (3), before the circuit breaker opened at 5, and nothing
retried it. The record then stayed missing or stale in search.

One rule now holds for every sink: a sink that is down stalls the pipeline
and loses nothing; only a change the sink rejects is parked.

- domain: sink errors are Permanent (the data), Unavailable (the sink) or
  transient. IsUnavailable also recognizes an open circuit, an attempt
  timeout and transport errors (refused, reset, dropped, DNS).
- sinks classify their sink-wide failures as Unavailable: Meilisearch no
  response, 5xx, 408, 429, 401, 403 and system/auth task errors; webhook
  5xx, 408, 429, 401, 403, 404; Redis loading, read-only, OOM, cluster or
  master down, auth, closed pool; NATS disconnected, no servers, timeouts,
  JetStream 5xx. Unencodable Meilisearch payloads and oversized NATS
  messages are Permanent.
- resilience: a failure the sink did not classify is Unavailable when the
  sink's health check fails too, once retries are spent.
- dlq: an unavailable failure is never counted toward the threshold,
  split or parked, and isolation stops as soon as the sink turns out to be
  down.
- service: an unavailable sink holds the batch in process and is retried
  with backoff (1s to 30s) until it takes it, without tearing the stream
  down, so the sinks that took the batch are not sent it again and a
  webhook resumes at the event that failed. The position is shared, so the
  other sinks wait: the slot can only be confirmed past a change every sink
  has.
- the stall is visible: /readiness is not ready and lists stalled_sinks
  and unhealthy_sinks, /api/stats marks the sink, cdc_sink_stalled{sink},
  and a warning when the stall starts, once a minute, and when it ends.

Dead letters are not retried automatically: replaying a parked event can
write an older version of a row over a newer one, and the queue now only
holds changes a sink rejected. POST /dlq/retry is unchanged.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G7VRX3LAZReXjVdthBP8WJ
@emoss08
emoss08 merged commit f511e98 into main Nov 18, 2026
7 checks passed
@emoss08
emoss08 deleted the search-outage-never-parks branch November 18, 2026 01:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant