Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
[lock] MultiMap lock - Thread is getting stuck on call of lock(key) #9055
I am using MultiMap implementation for my use case, I need to use MultiMap.lock(key) feature to make sure same key is not getting modified concurrently, i have noticed that the lock(key) method gets called and randomly the thread does not acquire a lock and get stuck forever, I have seen this behavior consistently but on random keys, no specific keys pattern. Most of the keys are unique, i would say 99% of them are unique but 1% of them may be duplicate and need to be handled in multi-threaded env and hence using lock(key) feature. My key column is of type String and using hazelcast and client with version 3.7
Is here any issue with lock feature of MultiMap, any help is very much appreciated..?
Yes, in finally block i unlock it, if it fails to unlock in finally block i force unlock it using try/catch block.
I read the documentation and it says locks are re-entrant so thread get stuck until it acquires the lock, the way code is written one thread should never hold a lock forever as it is force unlocked. //Do something is simple business logic so thread holding lock does not get stuck in there. I am not able to find out why the second thread is getting stuck on mmpa.lock(key) forever and does not proceed at all.
@pramodterdale Is this something that you can reproduce easily? Do you know or can you check if some other thread can acquire the lock even when one thread gets stuck on
Can you also try using the timed lock version -