Skip to content

merkle: wait for a dropped session's warm-up worker to stop - #975

Draft
citizen-stig wants to merge 1 commit into
thrumdev:masterfrom
citizen-stig:nikolai/fix-reopen-lock-after-dropped-session
Draft

citizen-stig wants to merge 1 commit into
thrumdev:masterfrom
citizen-stig:nikolai/fix-reopen-lock-after-dropped-session

Conversation

@citizen-stig

Copy link
Copy Markdown
Contributor

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 an unfinished session only disconnected the worker's channels, so the worker could outlive the Nomt. 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(..).

Fix: Drop for WarmUpHandle disconnects the channels and waits for the worker to report back, the same way ReverseDeltaBuilder waits for the rollback worker. The worker drops its Store before 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.rs reopens 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_sessions fuzz target.

🤖 Generated with Claude Code

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
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