Skip to content

fix: detect recycled macOS lock PIDs - #4252

Closed
AaronZ345 wants to merge 1 commit into
volcengine:mainfrom
AaronZ345:aaron/fix-darwin-stale-pid-lock
Closed

AaronZ345 wants to merge 1 commit into
volcengine:mainfrom
AaronZ345:aaron/fix-darwin-stale-pid-lock

Conversation

@AaronZ345

Copy link
Copy Markdown
Contributor

Summary

  • Add a Darwin process-identity check before treating a live PID as a valid OpenViking data-directory lock holder.
  • Treat macOS stale locks as recoverable when the recorded PID has been recycled by an unrelated process, matching the existing Linux intent more closely.
  • Add a regression test for a reused macOS PID held by mdwrite and adjust lock-error tests to avoid relying on real PID 1 semantics.

Root cause

_is_pid_alive() only validates process identity through /proc/<pid>/cmdline on Linux. macOS has no /proc, so a stale .openviking.pid left after reboot can be mistaken for an active OpenViking process when Darwin reuses that PID for a system daemon.

Fixes #4210.

Test plan

  • OV_PREBUILT_BIN_DIR=/tmp/openviking-ov-prebuilt OV_SKIP_RAGFS_BUILD=1 uv run --extra test pytest --no-cov tests/unit/test_process_lock.py → 38 passed, 4 warnings

Note: plain uv run --extra test pytest tests/unit/test_process_lock.py could not build locally because this machine does not have Cargo available to build openviking/bin/ov. I used a temporary prebuilt ov placeholder only for local Python test execution.

Verify Darwin lock holders before treating a PID as live so stale locks can self-heal after macOS reuses the recorded PID for an unrelated process.

Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com
@AaronZ345

Copy link
Copy Markdown
Contributor Author

Closing this draft because #4229 already covers the same issue with a broader, earlier implementation. Avoiding duplicate reviewer load.

@AaronZ345 AaronZ345 closed this Aug 24, 2026
@github-project-automation github-project-automation Bot moved this from Backlog to Done in OpenViking project Aug 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

macOS: stale PID lock misjudged as alive after reboot due to PID reuse — server crash-loops and never self-heals

1 participant