Skip to content

test: fix two flaky tests (maintenance lock, interrupted update worker) - #199

Merged
Derrors merged 2 commits into
mainfrom
fix/maintenance-test-flake
Nov 25, 2026
Merged

Derrors merged 2 commits into
mainfrom
fix/maintenance-test-flake

Conversation

@Derrors

@Derrors Derrors commented Nov 25, 2026

Copy link
Copy Markdown
Owner

What and why

Two tests that failed now and then in CI, fixed together (tests only, no product code).

  • maintenance::tests::pending_journal_blocks_other_installs_after_lock_owner_dies (CI on perf(viewer): one MJPEG stream per phone, one rotation sampler #188): it took the shared lease right after dropping the exclusive one. Another test that spawns a process meanwhile keeps a copy of the dropped descriptor in the child until it execs, and the lock with it. It now retries while the lock is held (as once_free does for the other test in the file), and checks that the first refusal is for the pending journal, not the lock (before, a held lock passed that assertion too). With a thread spawning true in a loop: 37 failures in 300 before, 0 in 300 after.
  • update::transaction::tests::recovers_after_process_death_using_only_durable_records (macOS CI on fix: low-level crates (review P0-C) #198; Linux locally on 2026-11-24): the worker it starts ended without being killed (signal() was None). Its output went to /dev/null, so the reason was lost.
    • The worker's output now goes to a file in the fixture directory and is shown when it isn't killed. A file, not a pipe: the fixture daemon the worker starts keeps the descriptor, and reading a pipe to its end waits for that daemon (a first try with output() hung).
    • Store::open is retried while the updater lock is held: the same race as above, for its non-blocking flock.
    • The fixture daemon's spawn is retried on ETXTBSY: the same race for the script just written, as archive.rs already does for the real candidate.
    • Neither race reproduced on Linux (60 runs under a process-spawning thread, 40 full test binaries at 32 threads), so these are the likely causes, not proven ones; if it fails again, the assertion now says why.

Tests

  • cargo test -p iphone-control update::: 41 passed; cargo test -p ictl-daemon maintenance: passed; clippy -D warnings
  • The whole iphone-control test binary 30 times at --test-threads=32: 0 failures, no hang
  • No test removed, ignored or loosened (the maintenance assertion is stricter)
  • Real device: not needed (tests only)

🤖 Generated with Claude Code

Derrors and others added 2 commits November 25, 2026 21:23
pending_journal_blocks_other_installs_after_lock_owner_dies took the
shared lease right after dropping the exclusive one. Another test that
spawns a process meanwhile holds a copy of the dropped descriptor in the
child until it execs, and the lock with it, so the last shared_in failed
now and then (CI on #188). With a thread spawning `true` in a loop it
failed 37 times in 300.

The test now retries while the lock is held (as once_free does for the
other test in the file), and checks that the first refusal is for the
pending journal, not for the lock: before, a held lock passed that
assertion too. 0 failures in 300 under the same load.

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
…failed

recovers_after_process_death_using_only_durable_records failed now and then
(macOS CI on #198, Linux locally on 2026-11-24): the worker it starts ended
without being killed, and its output went to /dev/null, so why was lost.

- the worker's output goes to a file in the fixture directory and is shown
  when it isn't killed (a file, not a pipe: the fixture daemon it starts keeps
  the descriptor, and reading a pipe to its end would wait for that daemon)
- Store::open is retried while the updater lock is held: another test that
  spawns a process meanwhile keeps a copy of a dropped lock's descriptor in the
  child until it execs, the race fixed for maintenance in the previous commit
- the fixture daemon's spawn is retried on ETXTBSY (text file busy), the same
  race for the script just written, as archive.rs does for the real candidate

Neither race reproduced on Linux (60 runs under a process-spawning thread, 40
full test binaries at 32 threads); the output will tell if it is another cause.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Derrors
Derrors merged commit 0f08bc3 into main Nov 25, 2026
7 checks passed
@Derrors
Derrors deleted the fix/maintenance-test-flake branch November 25, 2026 14:45
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