Giter Site home page Giter Site logo

Comments (4)

nightlyone avatar nightlyone commented on July 28, 2024

I believe this is handled by dead lock owner detection tested at

func TestRemovesStaleLockOnDeadOwner(t *testing.T) {
and later in that test.

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.

fioncat avatar fioncat commented on July 28, 2024

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 by B, 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.

fioncat avatar fioncat commented on July 28, 2024

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.

nightlyone avatar nightlyone commented on July 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.