Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
-
None
Description
ReentrantLock can be acquired multiple times in same thread. For multiple acquire call, ReentrantLock hold count is incremented by one.
So if we acquire lock multiple time from same thread, all will be successful and hold count is increased for every call.
But if we release lock, MemoryLocksService ignore the count and deletes the lock. Even if it's held by some command.
Simple step can reproduce it.
service.getWriteLock("test", 5000); //writeHoldCount = 1 MemoryLockToken lock = (MemoryLockToken)service.getWriteLock("test", 5000); //writeHoldCount = 2 lock.release(); //writeHoldCount = 1 lock = (MemoryLockToken)service.getWriteLock("test", 5000); //writeHoldCount = 1, it should be 2.
@Override public void release() { int val = rwLock.getQueueLength(); if (val == 0) { synchronized (locks) { locks.remove(resource); } } lock.unlock(); } }
MemoryLocks should check hold count before removing lock.
Attachments
Attachments
Issue Links
- breaks
-
OOZIE-2501 ZK reentrant lock doesn't work for few cases
- Closed
- links to