Skip to content

model-provider: every held-lock journal test takes its lock with the bounded retry - #419

Draft
SashaMIT wants to merge 1 commit into
developfrom
fix/model-journal-test-locks
Draft

SashaMIT wants to merge 1 commit into
developfrom
fix/model-journal-test-locks

Conversation

@SashaMIT

@SashaMIT SashaMIT commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #381.

What this changes

Four test sites in capsules/model-provider/src/journal.rs took the journal directory lock with a single try_lock().unwrap(): lines 3944, 3950, 4263 and 4336 on develop. They now take it with lock_journal_directory, the provider's own bounded retry (journal.rs:2167). Only test code changes. The provider's try_lock at :2172, inside that retry, is unchanged.

Why

5051505 (#381) found the cause. A child process that another test thread forks can hold a copy of an earlier lock fd for a short time, so a single try_lock() can return WouldBlock. That commit fixed one test: held_transaction_directory_lock_blocks_recovery_and_atomic_writes at journal.rs:4223, which is the failure Anders cites when he reopened #381 (alpha.22 develop push, run 38919906568, job 117040001433). The same pattern then failed in CI in another test:

thread 'journal::tests::live_transaction_creator_preserves_partial_files_and_bindings' panicked at src/journal.rs:4336:35:
called `Result::unwrap()` on an `Err` value: "WouldBlock"
test result: FAILED. 291 passed; 1 failed; 2 ignored

(job 117356008539, run 39018319086, test-capsules on #417's merge with develop.)

This PR fixes every remaining site at once, so the flake does not move to the next test. With 5051505 (already on develop) and this PR, every test in journal.rs that takes the directory lock itself uses the bounded retry. That is the first fix #381 proposes ("the test retries try_lock for a bounded time"). The other option it names, close-on-exec test fds before any fork, is not done here.

Proof

On this branch, cargo test --lib journal:: ran three times in a row:

test result: ok. 52 passed; 0 failed; 0 ignored; 0 measured; 242 filtered out; finished in 5.08s
test result: ok. 52 passed; 0 failed; 0 ignored; 0 measured; 242 filtered out; finished in 5.14s
test result: ok. 52 passed; 0 failed; 0 ignored; 0 measured; 242 filtered out; finished in 5.13s

cargo fmt -- --check and cargo clippy --all-targets with -D warnings are clean.

Gap: the flake depends on timing. Passing runs here do not prove the race is gone. It goes away because every test site now waits the same bounded time that the provider itself waits.

Merged into

This fix is merged into any open draft PR whose test-capsules job fails on this test. The first is #417.


Generated by Claude Code

…bounded retry

5051505 fixed one test. Four other test sites still took the journal
directory lock with one try_lock(). A child forked on another test thread
can briefly hold a copy of an earlier lock fd (#381), so they failed with
"WouldBlock" in CI (live_transaction_creator_preserves_partial_files_and_bindings,
journal.rs:4336, run 39018319086). They now use lock_journal_directory, the
provider's own bounded retry. Test code only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W6Qn9RX7LDqrwiAfNC2F2K
@SashaMIT

Copy link
Copy Markdown
Contributor Author

Review: A. The bounded retry matches the WouldBlock failure in run 39018319086. Ready for Anders once CI is green.

@SashaMIT

Copy link
Copy Markdown
Contributor Author

Round 3 review: PASS (A). Body, code and tests agree.

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.

2 participants