mirror of
https://github.com/paperclipai/paperclip.git
synced 2026-11-03 09:37:19 +01:00
A claim (marker write plus lease registration) and a teardown (marker read, lease count, then root delete or marker release) each read state and then act on it, as two separate filesystem calls. A concurrent claim could land in the gap between a teardown's read and its act: the teardown read zero other leases, a new admission then registered a lease and started using the root, and the teardown deleted or released that root anyway. Add a per-root gate file, opened with O_CREAT|O_EXCL like the marker claim, so a claim and a teardown for the same root run one at a time across every Runner process. A stale gate left by a crashed process is broken only when its holder process is provably gone. Co-authored-by: Paperclip <noreply@paperclip.ing>