Skip to content

Fix flaky Hub web service lock test - #13

Merged
DigitalPals merged 1 commit into
mainfrom
fix/ci-android-hub-lock
Nov 6, 2026
Merged

DigitalPals merged 1 commit into
mainfrom
fix/ci-android-hub-lock

Conversation

@DigitalPals

@DigitalPals DigitalPals commented Nov 6, 2026 •

Copy link
Copy Markdown
Owner

Fixes the intermittent Hub Runtime failure in runtime::tests::web_service_lock_is_exclusive_and_released_on_drop.

Cause: service_lock released its flock only by closing the file. A flock belongs to the open file description, and a child that another test thread is forking shares that description until its exec closes the O_CLOEXEC copy. So for that short window, the lock survived the drop and relocking failed. Fixture paths were already unique, so they weren't the cause.

Fix: service_lock now returns a ServiceLock guard that calls flock(LOCK_UN) on drop, so the lock is released immediately. The test is unchanged.

The Android platform-tools fix that this PR first carried landed on main in #9 in identical form. That PR also pins the amd64 Hub runner to ubuntu-24.04, which fixes the separate Tailscale/iptables step failure. This branch is rebased onto it.

Verification (local, project dev shell):

  • Temporary stress experiment (4 threads spawning processes while lock/drop/relock ×5000): 16/5000 failures before the fix, 0/15000 after. The experiment is not committed.
  • cargo test -p portal-hub web_service_lock ×60: all passed.
  • cargo test -p portal-hub: all passed, before and after the rebase. cargo fmt --check and cargo clippy -p portal-hub --all-targets -D warnings are clean.

🤖 Generated with Claude Code

service_lock relied on closing its fd to release the flock. A flock
belongs to the open file description, which a child forked by another
test thread shares until exec closes its O_CLOEXEC copy, so the lock
could outlive the drop and web_service_lock_is_exclusive_and_released_on_drop
failed intermittently. Return a guard that unlocks with LOCK_UN on drop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@DigitalPals
DigitalPals force-pushed the fix/ci-android-hub-lock branch from 0f25577 to c1138f9 Compare November 6, 2026 10:04
@DigitalPals DigitalPals changed the title Fix CI: Android SDK package and flaky Hub web lock test Fix flaky Hub web service lock test Nov 6, 2026
@DigitalPals
DigitalPals merged commit 4504b0a into main Nov 6, 2026
9 checks passed
@DigitalPals
DigitalPals deleted the fix/ci-android-hub-lock branch November 6, 2026 17:09
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