question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Clear old locks when server starts?

See original GitHub issue

If the server goes down while a task is running and has acquired a lock, the lock is still in place when the server comes back up. It isn’t released until the default timeout has expired and there doesn’t seem to be any clean mechanism for dealing with this.

A similar project to this called celery-singleton has a clear_locks API that removes any locks. This can be called when workers are first ready.

from celery.signals import worker_ready
from celery_singleton import clear_locks
from somewhere import celery_app

@worker_ready()
def unlock_all(**kwargs):
    clear_locks(celery_app)

Does such a mechanism exist for this project? Maybe I’m missing it. If it doesn’t exist, would this be a welcome feature?

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
CalebFentoncommented, Jun 16, 2019

Btw, if anyone is curious, this is really easy to do without any special API call:

@signals.worker_ready.connect
def unlock_all(**kwargs):
    lock_keys = redis_db.get('qo_*')
    redis_db.delete(*lock_keys)
1reaction
chpmrccommented, Jan 8, 2020

How would the proposed solution work with multiple workers connecting to the same backend? For example worker1 might set a lock, worker2 might crash, reinitialize and remove all locks on connect, which is obviously not ok.

EDIT: actually, now that I think about, the worst case seems to be an overlap of at most 2 tasks (assuming only one lock key is used), not a big deal.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to delete lock file if service failed to start - Super User
All you need to do is replace MyServiceName with the short name of your service and then put this batch file in your...
Read more >
File locks persisting after shutdown/restart (Causes ... - TechNet
When fast startup is enabled, a shutdown isn't really a shutdown, and powering the machine back on seemingly allows that interrupted process to ......
Read more >
Solution to remove lock after Application server redeployment
If the lock file won't delete, what is done is to kill the process, other options we do is to totally stop the...
Read more >
How to prevent samba from holding a file lock after a client ...
the below steps have helped me resolve this exact issue on a number of occasions: Login to the samba server. Run a "smbstatus"....
Read more >
Why do file geodatabase .lock files remain after a process is ...
Use the Compact geoprocessing tool in ArcCatalog to safely remove inactive .lock files from a file geodatabase. Navigate to ArcToolbox > Data ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found