Skip to content

fix: wait out a transient writer-lock duplicate and make the lock and doctor tests hermetic - #718

Merged
ajianaz merged 1 commit into
developfrom
fix/flaky-tests-2
Nov 14, 2026
Merged

ajianaz merged 1 commit into
developfrom
fix/flaky-tests-2

Conversation

@ajianaz

@ajianaz ajianaz commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

What

Fixes the spurious session is open for writing by pid N failure of session_effort_e2e::a_rejecting_provider_still_answers_without_the_parameter (#646), a related lock race in lock_writer, and a port-reuse race in doctor::tests::catalog_flags_an_unreachable_provider (#712).

Why

Changes

  • tole-core/src/storage.rs: the writer lock is now a WriterLock that registers its file identity in a process-wide set while held. A hold that names our own pid is retried (up to 20 s, in 5 ms steps) only when no handle of this process holds it; a real second open in this process (storage: no cross-process writer exclusion — a second writer corrupts the session file (live repro) #475) and any other holder still fail at once.
  • tests/writer_lock.rs: a_reopen_waits_out_a_long_lived_duplicate_of_a_closed_lock (a duplicate held for 700 ms; fails on the old 150 ms retry). The retried-pid test uses the same simulated duplicate.
  • tests/session_effort_e2e.rs: fork+exec of a child is serialised against fixture creation (SPAWN), plus a_resume_is_never_refused_by_children_forked_by_other_threads, which failed before the fix.
  • doctor.rs test: the dead port stays bound to a listener that hangs up on every connection.

Testing

  • Failing-before: a_reopen_waits_out_a_long_lived_duplicate_of_a_closed_lock fails on the old code; a_resume_is_never_refused_by_children_forked_by_other_threads failed 4 of 400 rounds without the mutex (taskset -c 0) and passes with it.
  • Stress, taskset -c 0, 4 busy loops, 64 test threads, 70 runs each: doctor::catalog_flags_an_unreachable_provider, tui_host::tree_after_fork..., delegate::an_independent_participant..., wire_size_missions all passed. These four were not reproduced (fewer than 200 runs), so the doctor and tui_host fixes follow from the analysis above and are not backed by a failing run; delegate and wire_size_missions are left unchanged.
  • cargo fmt, clippy --workspace --all-targets --all-features -D warnings, cargo test --workspace twice, tole-core --no-default-features, and session_effort_e2e with --no-default-features --features shell-tools: green.

Closes #646
Refs #712
Refs #702

…oaded machine

A reopen waits out a transient duplicate of a closed writer lock for up to 20 s when no handle of this process holds it, and still refuses a real second open at once. The session_effort e2e serialises fork+exec against fixture creation. The doctor unreachable-provider test keeps its port bound.
@github-actions

Copy link
Copy Markdown

🔍 Cora AI Code Review

✅ No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 5e81c35 into develop Nov 14, 2026
19 checks passed
ajianaz added a commit that referenced this pull request Nov 14, 2026
…again (#725)

## What

Gate the #718 lock-identity probe (`std::os::unix::fs::MetadataExt`,
dev/ino) behind `#[cfg(unix)]`; on non-unix it returns `None`.

## Why

`tole-core` stopped compiling on `x86_64-pc-windows-msvc` (E0433
`os::unix`, E0599 `dev`/`ino` at `storage.rs:1169`), which failed the
v0.11.0 release train's Windows build job (run 43574225374) while
Linux×2 and macOS stayed green. Windows has no fork, so the transient
duplicate-of-closed-descriptor retry (#552, #712) cannot occur there —
`None` restores the pre-#718 behavior where a self-pid hold is a real
hold. Unix behavior unchanged.

## Testing

- [x] `cargo check -p tole-core` clean
- [x] `cargo test -p tole-core --lib storage` 4/4 passed
- [ ] CI Windows job builds on this PR

Co-authored-by: ajianaz <[email protected]>
ajianaz added a commit that referenced this pull request Nov 14, 2026
## What

Release sync for v0.11.0 as ONE squash commit on a main-based branch:
main + the develop delta (release prep #723/#724 and the storage fix
#725). The commit's tree is identical to develop's tree (verified: git
diff of the two trees is empty), so the tagged tree equals the fully
validated tree.

## Why

The first v0.11.0 run (tag on e833469) failed x86_64-pc-windows-msvc:
#718's std::os::unix::fs::MetadataExt use had no cfg gate, so tole-core
did not compile on Windows (run 43574225374). #725 gates the probe
(Windows returns None; no fork there, so the transient-duplicate retry
never applies) and is on develop with 15/15 checks green. A merge-commit
sync (#727, closed) trips the message-standard check on 17 pre-ban
Co-authored-by trailers still in develop's v0.9/v0.10 history; a direct
develop->main PR (#726, closed) conflicts after the #724 squash merge.
The one-commit squash on a main-based branch carries the same content
with none of those problems.

## Testing

- [x] PR #725 (the fix): 15/15 checks green on develop
- [x] Local cargo check + storage tests 4/4; cross-check vs
x86_64-pc-windows-msvc shows no tole-core errors
- [x] This branch's tree == develop tree (content parity proven)
- [ ] This PR's CI green, then re-tag v0.11.0 to the new main HEAD

Co-authored-by: ajianaz <[email protected]>
ajianaz added a commit that referenced this pull request Nov 14, 2026
CI ran only on pull requests, and pull requests are squash-merged on stale bases, so nothing ever built the merged develop; that is how a missing cfg gate (#718) reached the v0.11.0 Release workflow. The push trigger of ci.yml now covers develop as well as main, so every merge to develop builds and tests the merged tree, including the Windows and macOS OS Check jobs and the Sandbox job. These runs are informational and not required checks.
@ajianaz
ajianaz deleted the fix/flaky-tests-2 branch November 20, 2026 08:39
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.

flaky test: session_effort_e2e::a_rejecting_provider_still_answers_without_the_parameter (session lock still held by the test process)

2 participants