Skip to content

flaky(macOS): spawn-lock post-release re-acquire can transiently report contention (flock close-release lag) #1340

Description

@zackees

Observed

daemon_ownership::tests::spawn_lock_is_exclusive_within_process failed on macOS CI (PR #1338 run, merge of current main): panicked at crates/fbuild-paths/src/daemon_ownership.rs:226:14: lock must be available after release — the post-release re-acquire through the error-propagating variant returned Ok(None) (kernel reported EWOULDBLOCK) immediately after the holder was dropped.

Analysis

  • fbuild_core::file_lock::FileLockGuard releases by dropping the File (close-release). The soldr reference implementation this lock pattern was copied from (soldr-daemon/src/daemon/lifecycle/mod.rs) instead calls file.unlock() explicitly in Drop.
  • This test family has macOS flake history: Flaky macOS CI: spawn-lock re-acquire and paused-time download retry test fail intermittently #1222 de-flaked the EINTR path; 5a0bc88 moved the post-release re-acquire assertion onto the error-propagating variant precisely because the swallowing wrapper can't distinguish contention from error.
  • The prod contract already treats a transient None as benign (callers poll/retry / fall back to herd-spawn), so the test should assert the eventual property, not a single-shot one.

Fix (in PR #1338)

  1. FileLockGuard::Drop performs an explicit unlock() before close, matching the soldr reference.
  2. spawn_lock_is_exclusive_within_process re-acquires with a short bounded retry (~1 s deadline, 10 ms poll), still hard-failing on I/O errors — the lock MUST become available, just not necessarily on the first nanosecond after release.

Note

Main is currently red on Check (macos-latest) for this test, which blocks every open PR's macOS check until this lands.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status
    Triage

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions