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.

Lock became infinite?

See original GitHub issue

Hi.

I have a lock defined as:

    lock = redis.Lock(
        "servicebook.tasks.emit_servicebook_notifications",
        expire=240,
        auto_renewal=True
    )

I’m acquiring it that way:

if lock.acquire(blocking=False):
  try:
    ...
  finally:
    lock.release()

Today our customer reported us an issue. Our background task, which relies on redis lock, was not executing. I’ve checked the key and I’ve found that:

127.0.0.1:6379> GET "lock:servicebook.tasks.emit_servicebook_notifications"
"GxwErhZvp2QmLvacH/pVgjGj"
127.0.0.1:6379> TTL "lock:servicebook.tasks.emit_servicebook_notifications"
(integer) -1

The TTL was set to infinite, so lock was always held.

Before I switched to lock.acquire(blocking=False) we had a code ran with blocking=True. Our background tasks are managed by RQ and sometimes they were killed due to timeout. To avoid timeouts I changed blocking=True to blocking=False. There were no other changes, upgrades nor manual changes to Redis db.

I wonder how it is possible that lock automatically changed its expiration time to infinite. There is a risk that this would happen again. Any thoughts? Feel free to ask anything If I can help somehow.

NOTE: We have several machines running same app servers (failover & load balancing).

Issue Analytics

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

github_iconTop GitHub Comments

1reaction
ionelmccommented, Jul 23, 2020

Just released v3.6.0. I hope it may fix the problem, or help you with the more strict option validation.

1reaction
ionelmccommented, Jul 23, 2020

Ok so I did some testing locally. It turns out one could do “lock.expire(-1)”. I think negative values should be disallowed. I’ll implement a fix.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The Infinite Lock | Dragongrin Wiki | Fandom
It's not clear when the Infinite Lock fell into terminal decline and became a half-sunken ruin. It's nearly impossible to get to by...
Read more >
going through the moves on infinite combo or game lock
If by infinite you mean infinite life/mana combos it works the same as above the player carrying out the combo elects a number...
Read more >
PICKUP CREATES AN INFINITE FLINCH LOCK - YouTube
I NEVER KNEW THIS EXISTED. SHARE THIS VIDEO WITH EVERYONE! I did not know Pickup had a competitive use, Im pretty sure like...
Read more >
Is Spartan Locke DEAD in Halo Infinite? (What happened to ...
What happened to Spartan Locke in halo Infinite campaign, and is Spartan Locke dead ? I think he will, lets talk about it!...
Read more >
Infinite loop caused by thread lock - Stack Overflow
Could anyone explain in detail the reason for an infinite loop because of the usage of locks. Test Code (that mimics the condition)...
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