Conversation
…bV1 (#1049) Move the ~70 LOC of byte-identical lifecycle scaffolding (status, wait_until_ready, clean_trailing, zaino_db_handler_sleep, shutdown) and the open_or_create_db helper from db/v0.rs and db/v1.rs into a single pub(super) trait DbLifecycle and a free fn in the parent db.rs. DbV0 and DbV1 now impl DbLifecycle via four field getters; their DbCore::{status, shutdown} delegate to the trait. The duplicated tokio::select! shutdown/abort block and the three-way sleep-or-maintenance body now live in one place. DbBackend::{status, shutdown} in db.rs use fully-qualified DbCore:: paths to disambiguate the two traits now in scope on DbV0/DbV1. #1033 (notify_one race) preserved verbatim on DbLifecycle::shutdown — fixing it is now a single-call-site change. Parent: #862 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… race DbLifecycle::shutdown signals waiters with Notify::notify_one, which wakes at most one task and stores at most one permit. With N > 1 tasks awaiting the same shutdown_notify, N-1 are stranded. Adds a maximally narrow test in db.rs::shutdown that impls DbLifecycle on a minimal FakeDb, spawns N=3 tasks each registering interest via Notified::enable + Barrier, then asserts every waiter completes within 200ms after shutdown returns. As intended, this test uniquely fails among the 226 in-package tests (225 passed, 1 failed, 2 skipped). The fix — switching the signaling primitive to a wake-all mechanism (watch, flag + notify_waiters, CancellationToken) — will flip it green and is tracked in #1033. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replaces Arc<Notify> + notify_one with tokio_util CancellationToken in
DbLifecycle. notify_one wakes at most one waiter and stores at most
one permit, so N>1 background tasks awaiting the same shutdown_notify
were stranded after shutdown. cancel() wakes every current waiter and
persists state for late subscribers; cancelled() handles the
late-poll case without an explicit register-before-wait dance.
Adds tokio-util = "0.7" to the workspace and zaino-state crate.
Trait change: shutdown_notify() -> &Arc<Notify> becomes cancel_token()
-> &CancellationToken. The two consumer sites (DbLifecycle::shutdown
notifier and zaino_db_handler_sleep waiter) and every Self {...} clone
literal across db/v0.rs, db/v1.rs, db/v1/write_core.rs, and
db/v1/compact_block.rs are updated to match.
Regression test from #1049 (db::shutdown::wakes_every_shutdown_waiter)
now passes — flips from the unique failure to a green invariant.
Closes #1033.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Hoists the inline status-polling closure in JsonRpcServer::spawn into a private async fn so the next commit can target it with a latency regression test before swapping the body for CancellationToken. Pure refactor: same 100ms-tick polling body, same call site semantics, no API change. Refs #1051 (parent tracking issue). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pre-requires: #1050
Fixes: #1052