Skip to content

fix: replication send failure counter and go subscribe error propagation - #325

Merged
kacy merged 1 commit into
mainfrom
fix/observability
Feb 27, 2026
Merged

fix: replication send failure counter and go subscribe error propagation#325
kacy merged 1 commit into
mainfrom
fix/observability

Conversation

@kacy

@kacy kacy commented Feb 27, 2026

Copy link
Copy Markdown
Owner

summary

two observability gaps from the audit — both involved silent failure modes that made production issues invisible.

H2 — replication broadcast: broadcast_replication in ember-core/src/shard/aof.rs discarded all send errors with let _ = tx.send(...). when a broadcast channel has no receivers, the send fails — this is expected when no replicas are connected, but there was no way to see it from metrics. now emits ember_replication_send_failures_total so operators can alert on unexpected replica disconnects in replicated deployments. also added an explanatory comment to the try_send in blocking.rs (client disconnect on BLPOP/BRPOP is expected and correct to ignore).

H3 — go client subscribe: the goroutine backing Subscribe exited silently on any recv error, closing the event channel with no indication of why. callers ranging over the channel had no way to detect network errors vs. normal stream end. introduces a Subscription type with a public C event channel and an Err() method. the goroutine sends the error to a buffered internal channel before exiting; Err() surfaces it. context cancellation is treated as a clean close (no error propagated), as that's intentional.

what was tested

  • cargo test -p emberkv-core — 591 passed, 0 failed
  • cargo build -p ember-server — clean
  • go client: go vet ./... passes on the updated file (pre-existing proto method errors are unrelated to this change)

**h2 — silent replication sends**: the `broadcast_replication` helper in
aof.rs previously discarded send errors with `let _ = tx.send(...)`. now
counts failed sends as `ember_replication_send_failures_total` so operators
can alert on unexpected replica disconnects in a replicated deployment.
adds `metrics` as a workspace dependency in ember-core. also documents the
expected-silent try_send pattern in blocking.rs.

**h3 — go subscribe error propagation**: the subscribe goroutine previously
returned silently on any recv error, leaving callers unable to distinguish
normal EOF from network or server errors. introduces a `Subscription` type
with a `C` event channel and an `Err()` method, and changes `Subscribe` to
return `(*Subscription, error)`. the goroutine now sends the recv error to
an internal buffered channel before exiting, which `Err()` exposes after C
is drained.
@kacy
kacy merged commit 72032cf into main Feb 27, 2026
4 of 7 checks passed
@kacy
kacy deleted the fix/observability branch February 27, 2026 01:57
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