New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support unlocking deadlocks with setnx/getset #4

Merged
merged 5 commits into from Jan 28, 2013

Conversation

Projects
None yet
2 participants
@miyagawa
Contributor

miyagawa commented Jan 23, 2013

This patch adds unlocking behavior when a worker somehow gets dead while obtaining a lock without cleaning it up and causes deadlocks. The code uses a design pattern used in http://redis.io/commands/setnx using SETNX and GETSET, to avoid the race condition.

To make it work i changed the value of lock to be an integer (UNIX timestamp) rather than a time string as it used to be.

This addresses #1.

@miyagawa

This comment has been minimized.

Show comment
Hide comment
@miyagawa

miyagawa Jan 23, 2013

Contributor

The commits also bump up the resque dependency to work with the current release of resque. I've been running it on production for a couple of days now and see no problems with the current resque.

Contributor

miyagawa commented Jan 23, 2013

The commits also bump up the resque dependency to work with the current release of resque. I've been running it on production for a couple of days now and see no problems with the current resque.

@miyagawa

This comment has been minimized.

Show comment
Hide comment
@miyagawa

miyagawa Jan 23, 2013

Contributor

FWIW, 5 days is awfully long for a deadlock situation - I override that by defining our own def lock_timeout but that might not be obvious without looking at the source code. Might be worth adding a documentation?

Contributor

miyagawa commented Jan 23, 2013

FWIW, 5 days is awfully long for a deadlock situation - I override that by defining our own def lock_timeout but that might not be obvious without looking at the source code. Might be worth adding a documentation?

@wallace

This comment has been minimized.

Show comment
Hide comment
@wallace

wallace Jan 28, 2013

Owner

Excellent, thank you!

Owner

wallace commented Jan 28, 2013

Excellent, thank you!

wallace added a commit that referenced this pull request Jan 28, 2013

Merge pull request #4 from miyagawa/master
Support unlocking deadlocks with setnx/getset

@wallace wallace merged commit 04786eb into wallace:master Jan 28, 2013

@miyagawa

This comment has been minimized.

Show comment
Hide comment
@miyagawa

miyagawa Mar 8, 2013

Contributor

There's some race condition reported in redis-mutex, which uses the same SETNX pattern: kenn/redis-mutex#5

I will need to see how they can get the issue fixed and if that can be applied to your gem too :)

Contributor

miyagawa commented Mar 8, 2013

There's some race condition reported in redis-mutex, which uses the same SETNX pattern: kenn/redis-mutex#5

I will need to see how they can get the issue fixed and if that can be applied to your gem too :)

@wallace

This comment has been minimized.

Show comment
Hide comment
@wallace

wallace Mar 9, 2013

Owner

Hm, I may have time to tackle this later this week.

Owner

wallace commented Mar 9, 2013

Hm, I may have time to tackle this later this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment