Repository navigation
merkle: wait for a dropped session's warm-up worker to stop - #975
Draft
citizen-stig wants to merge 1 commit into
Draft
citizen-stig wants to merge 1 commit into
citizen-stig wants to merge 1 commit into
Conversation
With `warm_up` enabled, each session runs its warm-up on a detached thread that holds a `Store`, and with it the database directory lock. Dropping a session without finishing it only disconnected the worker's channels, so the worker could still be running when the `Nomt` was dropped. Reopening the same path right away then failed with "Failed to lock directory: Resource temporarily unavailable": in 226 of 300 tries of `drop(session); drop(nomt); Nomt::open(..)`. Give `WarmUpHandle` a `Drop` that disconnects the channels and waits for the worker to report back, as `ReverseDeltaBuilder` already does for the rollback worker. The worker drops its `Store` before reporting. A finished session's output has already been taken, so its drop returns at once. Dropping an unfinished session now takes ~20-40us instead of ~0. Found by the concurrent_sessions fuzz target. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017wb3qEWY4XggAP3mPx3c1a
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.
With
warm_upenabled, each session runs its warm-up on a detached thread that holds aStore, and with it the database directory lock. Dropping an unfinished session only disconnected the worker's channels, so the worker could outlive theNomt. Reopening the same path right away then failed withFailed to lock directory: Resource temporarily unavailable, in 226 of 300 tries ofdrop(session); drop(nomt); Nomt::open(..).Fix:
Drop for WarmUpHandledisconnects the channels and waits for the worker to report back, the same wayReverseDeltaBuilderwaits for the rollback worker. The worker drops itsStorebefore it reports. A finished session's output has already been taken, so its drop returns at once. Dropping an unfinished session now takes ~20–40 µs instead of ~0.Test:
tests/reopen_after_drop.rsreopens the database 50 times, each time right after dropping sessions that have warm-ups in flight. It fails without the fix.This is independent of #974. Without #974, the worker still panics (the panic is caught) before this drop returns.
Found by the
concurrent_sessionsfuzz target.🤖 Generated with Claude Code