ReadLock not working correctly
See original GitHub issueHi,
Is this the expected behaviour of the ReadLock from ReadWriteLock?
Clarifying because I did not encounter this in release 3.5.4
There are multiple threads that are trying to lock and unlock the readlock concurrently but I am encountering the “attempt to unlock lock, not locked by current thread by node id” exception.
Here is a rough code sample to replicate the issue.
ExecutorService service;
RReadWriteLock rwlock;
RLock rlock = rwlock.readLock();
for (int i=0; i<10; i++) {
service.submit (() -> {
for (int j=0; j<1000; j++) {
rlock.lock();
try {
} finally {
try {
rlock.unlock();
} catch(Exception e) {
e.printStackTrace();
}
}
}
});
}
The unlock part throws the following exception even though they’re all read locks.
java.lang.IllegalMonitorStateException: attempt to unlock lock, not locked by current thread by node id: e3784ec0-94c6-4138-ac2a-1865eb79c93d thread-id: 21
at org.redisson.RedissonLock.unlock(RedissonLock.java:367)
at Main.lambda$0(Main.java:25)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Issue Analytics
- State:
- Created 6 years ago
- Comments:36 (16 by maintainers)
Top Results From Across the Web
FLUSH TABLES WITH READ LOCK not working?
I use this command to "lock" my database, flush logs , take a LVM snapshot and release it. Testing the recover + binlogs...
Read more >Apache Camel - "Cannot acquire read lock" - Stack Overflow
I'm using Apache Camel version 2.24.2. I have two application servers that are polling a shared directory to pick up and process files....
Read more >ReentrantReadWriteLock.ReadLock (Java Platform SE 7 )
Acquires the read lock if the write lock is not held by another thread within the given waiting time and the current thread...
Read more >ReentrantReadWriteLock blocks obtaining read lock after ...
A ReentrantReadWriteLock with "FAIR" policy does not show this behaviour STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : - Create a ReentrantReadWriteLock ...
Read more >SFTP readLock option - users@camel.apache.org
readLock =rename works, but just not sure in a cluster. Claus Ibsen. 10 years ago ... Assuming I read your question correctly, the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
this error happens in 3.11.5. which version fixed this issue?
@mrniko I changed async way to use redisson, also made
waitLockTime > lockLeaseTime
, this issue disappeared . this change has been put into production for several weeks, so i believe my usage was error, I/O thread was blocked somewhere.