Skip to content

test(desktop): make the instance-guard flake diagnosable - #852

Merged
huichen merged 1 commit into
mainfrom
fix/instance-flake-diagnostic
Sep 25, 2026
Merged

huichen merged 1 commit into
mainfrom
fix/instance-flake-diagnostic

Conversation

@huichen

@huichen huichen commented Sep 25, 2026

Copy link
Copy Markdown
Collaborator

The problem with reporting this as a bug

instance::tests::excludes_second_owner_and_releases_on_drop failed 3 times in ~20 full-suite runs and never once in isolation (150 single runs, 320 concurrent runs of the same test binary, several further full-suite runs).

Each failure printed only:

assertion failed: InstanceGuard::at(directory.path()).is_ok()

Which says nothing about why. I captured the real message this time, and it corrected my own earlier assumption: the failure is on the re-acquire after drop(guard), not on the contended-acquire assertion I had suspected.

That leaves two candidates pointing at completely different owners:

  • the lock was not released when the guard dropped → a real product bug
  • the open failed for an unrelated reason (an environmental race) → a test issue

A bare is_ok() cannot distinguish them.

What this change does

Reports the error. Nothing else — the test asserts exactly what it did before.

What this change does not do

It does not fix the flake. I could not reproduce it on demand, so I have no evidence for a root cause and will not invent one. The value is that the next occurrence is diagnosable instead of costing another investigation.

Already ruled out

File-descriptor exhaustion. My working assumption, since this host has a soft limit of 2560 and the suite opens sockets, locks and temp files. The full suite runs 1312 tests green under ulimit -n 256, so the library's own fd use is not near the limit. Hypothesis dead.

Verification

cargo test --lib instance:: → 3 passed; cargo fmt --check and cargo clippy --all-targets --manifest-path desktop/src-tauri/Cargo.toml -D warnings clean on pinned 1.97.

Why it is not bundled with the payload-trim PR

It was written while working in that branch, but it is unrelated in subject and would blur that PR's rollback boundary. If the cause turns out to be a product bug, it deserves its own fix and its own discussion.

`excludes_second_owner_and_releases_on_drop` failed 3 times in ~20 full-suite
runs and never once in isolation (150 single runs, 320 concurrent runs of the
same test binary, several full-suite runs). Each time with only:

    assertion failed: InstanceGuard::at(directory.path()).is_ok()

That says nothing about *why*. The failure is on the re-acquire **after**
`drop(guard)` — not on the contended-acquire assertion, which is what I had
assumed before capturing the real message — so the two candidates are "the lock
was not released" and "the `open` failed for an unrelated reason". Those point
at completely different owners, and one of them is a real product bug.

The assertion now reports the error, so the next occurrence is diagnosable
instead of costing another investigation. No behaviour change: the test asserts
exactly what it did before.

One hypothesis already ruled out: **file-descriptor exhaustion**. The suite runs
1312 tests green under `ulimit -n 256`, so the library's own fd use is not
near the limit.

Not fixed — diagnosed. This is deliberately not part of the payload-trim PR
(#849): unrelated subject, and it should be reconsidered if the cause turns out
to be a product bug.
@huichen
huichen enabled auto-merge (squash) September 25, 2026 19:26
@huichen
huichen merged commit daf716f into main Sep 25, 2026
12 checks passed
@huichen
huichen deleted the fix/instance-flake-diagnostic branch September 25, 2026 19:35
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