You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The deploy lock is .git/deploy-lock, a JSON file holding the holder's PID and a timestamp. acquire() breaks a lock whose PID is no longer running (a stale lock).
#31 fixed a check-then-write race in acquire(): two deploys starting together could both see the lock free and both proceed. Acquirers now take an fcntl.flock on .git/deploy-lock.guard while they check and write the lock. That's correct, but there are now two mechanisms: the flock guard serializes acquirers, and the PID file plus stale-PID detection decide who holds the lock.
Proposal
Make the flock the lock. Hold an exclusive flock on .git/deploy-lock for the whole deploy, non-blocking, so a second deploy gets "locked" immediately:
The kernel releases a flock when its holder exits, however it exits, so there's no stale-lock case and no PID liveness check.
Keep writing the PID and timestamp into the file, but only for the "lock held by PID N" message.
release() becomes closing the file descriptor.
Worth it?
Possibly not. The current implementation is correct and tested, including an 8-process concurrency test. The gain is less code and one mechanism instead of two, and the PID-reuse edge case (a stale lock whose PID was reused by an unrelated process looks held) disappears. Do it if the lock is touched again for another reason.
Size
Small: about 30–50 lines in src/flow_deploy/lock.py and tests/test_lock.py. Low to medium risk: lock semantics on NFS-mounted .git would need a check, since flock over NFS varies.
Activity