Skip to content
This repository has been archived by the owner on May 5, 2021. It is now read-only.

Question: how do you keep the lock #17

Open
osallou opened this issue Mar 18, 2016 · 3 comments
Open

Question: how do you keep the lock #17

osallou opened this issue Mar 18, 2016 · 3 comments

Comments

@osallou
Copy link

osallou commented Mar 18, 2016

Once A has acquired the lock, set with a timeout of 10 seconds for example.
How can A keep the lock, within the 10 seconds, to prevent B to take it?
I see no method to renew the lock.

I expect A to keep the lock as long as necessary, then B takes it only if A fails (and ttl will remove the lock) or A releases the lock.

Thanks

@optimuspaul
Copy link
Contributor

That does sound like a good feature request. My advice for now would be obtain locks with timeouts much longer than you expect you'd need.

I don't know if you'd read this, http://martin.kleppmann.com/2016/02/08/how-to-do-distributed-locking.html, but a lot of concerns about the safety of redlock have been brought up. I personally like the simplicity of redlock and in my use only use it for advice and not as a guarantee.

There is always the possibility that A fails to complete it's task before the timeout occurs, which is why you would never want to use redlock in a critical scenario unless you were also using a CAS of some sort to deal with conflict.

@osallou
Copy link
Author

osallou commented Mar 19, 2016

I indeed read article. A longer ttl will not fit for a process willing to
keep forever until stopped, released or crashed.
The random value obtained with the lock could be used certainly to allow an
expiration update only if value match, just like for releasing it.

Le ven. 18 mars 2016 18:52, Paul DeCoursey notifications@github.com a
écrit :

That does sound like a good feature request. My advice for now would be
obtain locks with timeouts much longer than you expect you'd need.

I don't know if you'd read this,
http://martin.kleppmann.com/2016/02/08/how-to-do-distributed-locking.html,
but a lot of concerns about the safety of redlock have been brought up. I
personally like the simplicity of redlock and in my use only use it for
advice and not as a guarantee.

There is always the possibility that A fails to complete it's task before
the timeout occurs, which is why you would never want to use redlock in a
critical scenario unless you were also using a CAS of some sort to deal
with conflict.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#17 (comment)

@xq5he
Copy link

xq5he commented Jan 14, 2017

@osallou Actually, set will return null if the key has been set. So this check will be Flase if the resource has been locked by other client.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants