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.

Is there another race condition when a lock is released?

See original GitHub issue

https://github.com/ionelmc/python-redis-lock/blob/a30bd138f0f3060cc1f51d6a377b4067fae4dda9/src/redis_lock/__init__.py#L362-L368

As shown above, the step to release the lock is 1. Execute the UNLOCK script 2. Execute the _delete_signal function. Consider a situation with two processes:

  • Process 1 currently holds a lock.
  • process 2 is ready to acquire the lock.

Now, suppose that the following sequence of events unfolds:

  • process 2 executes the SETNX command to obtain the lock but does not get it.
  • Process 1 executes the UNLOCK script to release the lock.
  • process 1 executes the _delete_signal function.
  • process 2 executes the BLPOP command. It then waits for a timeout to acquire the lock again, and that’s the problem.

So I wonder why there ended up with a _delete_signal function. Can you explain it a little bit?

I think this guy’s got the same problem. https://github.com/ionelmc/python-redis-lock/issues/58#issuecomment-348712157

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ionelmccommented, Nov 8, 2019

But does it work or get stuck? Or are you just complaining about efficiency?

0reactions
ionelmccommented, Dec 6, 2019

Released v3.4.0.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Race conditions and deadlocks - Visual Basic - Microsoft Learn
At least two threads are waiting for a variable that the other thread locked. The threads do not proceed, because neither thread will...
Read more >
Reading 23: Locks and Synchronization
Deadlock. When used properly and carefully, locks can prevent race conditions. But then another problem rears its ugly head. Because the use of...
Read more >
Race Conditions, Locks, Semaphores, and Deadlocks - Medium
A lock or mutex (from mutual exclusion) is a synchronization mechanism for enforcing limits on access to a resource in an environment where ......
Read more >
What prevents a race condition on a lock?
When lock is equal to 0 another thread can enter to critical section - while loop ends. Thread suspending - for example counting...
Read more >
Is there a race condition when a lock is released? #58 - GitHub
Now, suppose that the following sequence of events unfolds: Process 1 executes the UNLOCK script to release the lock. Pr...
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