[local storage] Remove IPC lock file after releasing the lock - #2172
[local storage] Remove IPC lock file after releasing the lock#2172Sanjays2402 wants to merge 1 commit into
Conversation
fasteners.InterProcessLock creates its lock file but never removes it, and LockLocalStorage did not remove it either. Because the file name is derived from a sha256 of the locked path, one file was left behind in the temporary directory for every distinct path ever locked, which can exhaust inodes on long running processes that write many objects. The lock file is now removed after the IPC lock is released. Closes apache#1975
micafer
left a comment
There was a problem hiding this comment.
Removing the lock file immediately after releasing InterProcessLock introduces a race which can break mutual exclusion.
For example, process B may acquire the existing file lock immediately after process A releases it. A can then unlink the path, and process C can create and lock a new file at the same path. B and C would consequently hold locks on different inodes and could both enter the critical section.
The new test only verifies that the file is removed in a non-concurrent scenario, so it does not cover this race or verify that mutual exclusion is preserved.
I don't think the lock file can safely be removed as part of exit. We likely need a different bounded-lock or out-of-band cleanup strategy.
|
You're right, and the race is worse than the ordering I had in mind. Even if I move the The only ways I can see to make it safe are all heavier than the leak deserves:
And the thing being leaked is a zero-byte file per distinct locked path, bounded by the set of paths the process touches, in a directory the OS already reclaims. That's a poor trade against any risk to mutual exclusion. So I'll concede this one — the approach in the PR is not fixable in place. Happy to close it. If you think the age-based sweep is worth having as a separate change I can open that instead, but I'd rather you say so than have another speculative PR land in your queue. |
Closes #1975
Description
fasteners.InterProcessLockcreates its lock file but never removes it, andLockLocalStorage.__exit__did not remove it either. The file name is a sha256of the locked path, so one file was left behind in the temp directory for every
distinct path ever locked -- a long running process writing many objects can
exhaust inodes. The lock file is now removed after the IPC lock is released.
Status
done, ready for review
Checklist (tick everything that applies)