Skip to content

fix(digest): drain queue and flush on channel close; graceful shutdown - #351

Merged
ajianaz merged 2 commits into
developfrom
fix/331-digest-drain
Oct 13, 2026
Merged

ajianaz merged 2 commits into
developfrom
fix/331-digest-drain

Conversation

@ajianaz

@ajianaz ajianaz commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

What

  • DigestTask::run: handle rx.recv() == None explicitly (flush partial batch, break). Previously the Some(..) pattern only disabled the branch while the interval branch stayed ready, so the loop never exited.
  • main.rs: add SIGINT/SIGTERM graceful shutdown (bounded 10s HTTP grace), drop the server/router state so ingest_tx closes, then await the digest task with a 10s timeout instead of abort().

Why

Events already acked with HTTP 200 (buffered batch + queued in the mpsc) were lost on SIGTERM/restart. Closes #331

Testing

  • New tests drains_partial_batch_and_exits_on_channel_close and drains_multiple_batches_on_channel_close; both FAIL on the old loop (timeout, task never exits) and pass now.
  • cargo fmt --check: OK
  • cargo clippy --workspace --all-targets -- -D warnings: clean
  • cargo test --workspace: all pass

Deferred: webhook/ws consumers not changed (WS bridge ends when digest drops its sender).

🤖 Generated with Claude Code

ajianaz and others added 2 commits October 13, 2026 08:36
The digest select loop never observed channel closure (the interval
branch was always ready), and main aborted the task after serve returned,
losing acked events. Handle recv() == None by flushing and exiting, add
SIGINT/SIGTERM graceful shutdown, and await the digest task with a
bounded timeout instead of abort().

Closes #331

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@ajianaz
ajianaz merged commit e3918e4 into develop Oct 13, 2026
16 checks passed
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.

bug(pipeline): digest never drains on channel close; events lost on shutdown

1 participant