Giter Site home page Giter Site logo

regolancer.lock not deleted about regolancer HOT 5 CLOSED

rkfg avatar rkfg commented on July 30, 2024
regolancer.lock not deleted

from regolancer.

Comments (5)

rkfg avatar rkfg commented on July 30, 2024 1

It's a technicality, there's no way in the library we use to delete that file and I showed why it's not a good idea in our case. If you're supposed to run exactly one instance of software and it holds the lock during the entire run time then I think it might be deleted safely on exit. But people run multiple regolancer instances, up to 40 in parallel, so deleting the lock might cause unexpected race conditions this lock should prevent exactly.

from regolancer.

rkfg avatar rkfg commented on July 30, 2024

See gofrs/flock#41. I suppose it's unsafe to delete lock files in general if we expect many processes to run in parallel. Consider this situation:

  • process1 acquires the lock for writing
  • process2 tries to do the same but is blocked because of process1
  • process1 finishes the work, unlocks the file
  • process2 quickly locks it to itself
  • process1 doesn't know that, deletes the file and exits (here it would fail on Windows but not on *nix)
  • process3 attempts to acquire the lock, the file doesn't exist so it creates and locks a new one with the same name
  • process2 still uses the (now deleted) lock
  • process3 also uses the lock because it created a different file with the same name

And here we have process2 and process3 using the "exclusive" lock together at the same time.

from regolancer.

feelancer21 avatar feelancer21 commented on July 30, 2024

But this means, that I have to delete the lock by myself before starting a new run? Otherwise, I think, no process can write in the db.

from regolancer.

rkfg avatar rkfg commented on July 30, 2024

Have you tried just running the program? I never deleted the lock and it all worked fine even when I ran 3-4 processes at once. The mere presence of that file doesn't mean it's locked, flock is a special syscall (see man 2 flock) which places a lock on an existing file or blocks if it's already present. That's why we use a library for this and not simply create/check for an empty file, this stuff isn't cross platform and needs explicit support with platform API.

Oh, and also we don't have a db except the optional CSV stat file. It's currently not protected by the lock but it will be soon. If you mean the node cache, it's also not a db but a gob dump and it's only written when the program terminates. This is protected by the lock.

from regolancer.

feelancer21 avatar feelancer21 commented on July 30, 2024

The program seems to work. But sometimes there is a difference between what you see and what happens.
But I am not so deep in the technical details. I was just wondering because the file existis and worried that there is still something locked. And yes I mean the node cache.

from regolancer.

Related Issues (20)

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.