hemantk-12 commented on PR #5968:
URL: https://github.com/apache/ozone/pull/5968#issuecomment-1885986128

   @aswinshakil actually you are right (Good catch), even after the 
synchronized cleanup, it is possible the thread is waiting for the lock which 
is acquired by another thread.
   
   For example,
   At timet0 Thread 1 -> Acquires lock for snap1
   At timet0 Thread 2 -> Acquires lock for snap2
   
   Now thread one acquires the cleanup() lock and starts the clean up, but it 
will stuff for snap2 lock because it has not been released so far.
   At time t1 Thread 1 -> Waiting for lock snap2
   
   Moving out cleanup in get function out of the lock should fix it.
   
   After the change,
   At timet0 Thread 1 -> Acquires lock for snap1 -> does dbMap#getOrCompute() 
-> release the lock
   At timet0 Thread 2 -> Acquires lock for snap2 -> does dbMap#getOrCompute() 
-> release the lock
   
   One of the thread will acquire the cleanup lock because it is synchronized. 
Let's say, Thread 1 gets it.
   At time t1 Thread 1 -> acquire the cleanup lock -> acquire snap1 (and other 
keys sequentially) lock -> remove the entry if possible -> release snap1 lock 
-> release clean up lock.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to