fix(lock): recover same-process stale palace lock - #1977
Conversation
|
/gemini review |
|
@fatkobra the failure mode this recovers should already be gone on develop: #1859 made the re-entrancy marker process-wide, so a second acquire in the same process passes through instead of failing with its own PID. I couldn't reproduce the self-deadlock on current develop; the new test only hits it by taking the flock through a handle opened outside The unlink also worries me: after Also heads-up: this rewrites the same lines as #1971 (which moves |
|
Thanks @mvalentsev — I agree with this concern too. I’m going to stop this PR unless I can reproduce the self-deadlock on current I also agree that unlinking the lock file is too risky because it can create two lock inodes for the same palace. That is worse than the original failure because it can allow two writers. I’ll close this instead of trying to land the unlink approach. |
What does this PR do?
Closes and Fixes #1924 by adding narrow same-process stale-lock recovery to
mine_palace_lock().When lock acquisition fails and the lock file says the holder PID is this same process, the process has self-deadlocked on a stale/leaked flock FD. The patch unlinks that pathname and retries once. This matches the verified workaround from the issue while keeping the safety boundary tight.
Safety properties
os.getpid().How to test
Added
tests/test_palace_lock_self_deadlock.pycovering:Run:
Checklist
python -m pytest tests/ -v)ruff check .)