Netflix/curator — Issue #9: InterProcessMutex questions
Author: Randgalt
Created: 2011-12-06 21:34:56+00:00
State: open

-- From John Laban, PagerDuty Inc

I've been dabbling with Curator and it's very nice. I had a few quick questions about it and I was hoping you could help me. If there's a mailing list or somewhere I should be directing these questions, I'd be happy to send them there instead.

I'm mainly using Curator currently for the InterProcessMutex recipe.

1) Based on the name, I'm guessing that InterProcessMutex doesn't work intra-process, right? To prevent two threads in the same process from acquiring the same lock at the same time, I'll have to layer some other lock on top? (Like a java.util.concurrent.locks.ReentrantLock).

2) I want to make sure that no two processes think they own the lock at the same time, even if one of those processes disconnects from ZooKeeper part way through a transaction. It sounds like a ConnectionStateListener is the way to detect this... is the listener notified immediately upon a disconnect, or is there a delay? (Also: do you know if there's any way to configure Zookeeper so that ephemeral nodes take a few seconds to disappear after a session ends? This would fix the problem too, afaict, although I don't think it's possible.)

3) Have you thought about implementing read vs write locks? (Or is there a recipe that I missed?)

Thanks for the help, and thanks a ton for putting this client out there,
John Laban
PagerDuty Inc