Comments (4)
I believe this is handled by dead lock owner detection tested at
Line 190 in bf01bef
Could you please provide a minimal test case to reproduce the observed behaviour?
Do you try using it wih filesystem shared between multiple hosts or using different PID namespaces on Linux?
from lockfile.
I didn't use multiple hosts or pid namesapce.
When this case happended, there had many pids in my machine.
So I guess this was caused by pid-reuse:
- program
A
lock pid - program
A
crashed, the lock wasn't released - another irrelevant program
B
reused this pid - program
C
try to lock, but the pid was used byB
, failed
The B
should not block C
, but the OS may assign the pid to it, this is unpredictable.
Because Linux does not allow specifying the pid when creating a process, it is hard to simply reproduce now. But it does happen when the number of pids is in pressure.
from lockfile.
The Linux syscall flock
solved this for me, so I created anthor filelock lib based on flock
: ucloud/go-lockfile.
But this is not a cross-platform solution.
from lockfile.
One approach would be to also store the process start time and compare this with stored data in the PID file. But that would be backward incompatible.
Another approach would be to compare the process start time with the mtime (modification time) of the lock file and assume a stale file if that file has an much older mtime. That approach would be backward compatible.
Both approaches require to see the process start time of the process with the same PID. I am not sure how feasible and portable this approach may be.
from lockfile.
Related Issues (13)
- Failer on windows when pid is from dead process HOT 10
- return better error on Unlock/Trylock race HOT 2
- Automatic retries HOT 1
- License file is MIT but readme says the project is BSD HOT 1
- Documentation of algorithm constraints and fail on their violation HOT 2
- Locking fails in vboxfs because hard links are not possible. HOT 4
- non-recursive lock
- lock failed when program restart after crash HOT 6
- Stop file from being deleted (win, mac, linux) HOT 1
- Use symlinks instead of hardlinks on unix platforms HOT 7
- circular imports not allowed HOT 4
- Dependency Dashboard
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lockfile.