{"action":"created","issue":{"url":"https://api.github.com/repos/ben-manes/caffeine/issues/203","repository_url":"https://api.github.com/repos/ben-manes/caffeine","labels_url":"https://api.github.com/repos/ben-manes/caffeine/issues/203/labels{/name}","comments_url":"https://api.github.com/repos/ben-manes/caffeine/issues/203/comments","events_url":"https://api.github.com/repos/ben-manes/caffeine/issues/203/events","html_url":"https://github.com/ben-manes/caffeine/issues/203","id":273728632,"number":203,"title":"Deadlock in NonReentrantLock","user":{"login":"agoston","id":3763887,"avatar_url":"https://avatars0.githubusercontent.com/u/3763887?v=4","gravatar_id":"","url":"https://api.github.com/users/agoston","html_url":"https://github.com/agoston","followers_url":"https://api.github.com/users/agoston/followers","following_url":"https://api.github.com/users/agoston/following{/other_user}","gists_url":"https://api.github.com/users/agoston/gists{/gist_id}","starred_url":"https://api.github.com/users/agoston/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agoston/subscriptions","organizations_url":"https://api.github.com/users/agoston/orgs","repos_url":"https://api.github.com/users/agoston/repos","events_url":"https://api.github.com/users/agoston/events{/privacy}","received_events_url":"https://api.github.com/users/agoston/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":29,"created_at":"2017-11-14T09:52:38Z","updated_at":"2017-11-23T00:08:31Z","closed_at":null,"author_association":"NONE","body":"Under heavy load of JVM, we are experiencing deadlocks in caffeine version 2.5.6.\r\n\r\nHere is the threaddump of the two threads in deadlock:\r\n\r\n```\r\n\"ajp-0.0.0.0-8109-59 (P6V7aMaZbbXkfaYzYzXxID0tvHylFQJumanAAABmA)\":\r\n        at sun.misc.Unsafe.park(Native Method)\r\n        - parking to wait for  <0x000000032a600bb8> (a com.github.benmanes.caffeine.cache.NonReentrantLock$Sync)\r\n        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)\r\n        at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836)\r\n        at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:870)\r\n        at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1199)\r\n        at com.github.benmanes.caffeine.cache.NonReentrantLock$Sync.lock(NonReentrantLock.java:315)\r\n        at com.github.benmanes.caffeine.cache.NonReentrantLock.lock(NonReentrantLock.java:78)\r\n        at com.github.benmanes.caffeine.cache.BoundedLocalCache.performCleanUp(BoundedLocalCache.java:1096)\r\n        at com.github.benmanes.caffeine.cache.BoundedLocalCache.afterWrite(BoundedLocalCache.java:1017)\r\n        at com.github.benmanes.caffeine.cache.BoundedLocalCache.put(BoundedLocalCache.java:1655)\r\n        at com.github.benmanes.caffeine.cache.BoundedLocalCache.put(BoundedLocalCache.java:1602)\r\n        at com.github.benmanes.caffeine.cache.LocalManualCache.put(LocalManualCache.java:64)\r\n```\r\n\r\nand\r\n\r\n```\r\n\"ajp-0.0.0.0-8109-78 (-jIkyghhBePEsLll9i5dnGr65Dx8PfahGe2gAABxE)\":\r\n        at sun.misc.Unsafe.park(Native Method)\r\n        - parking to wait for  <0x000000032a600bb8> (a com.github.benmanes.caffeine.cache.NonReentrantLock$Sync)\r\n        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:175)\r\n        at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:836)\r\n        at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:870)\r\n        at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1199)\r\n        at com.github.benmanes.caffeine.cache.NonReentrantLock$Sync.lock(NonReentrantLock.java:315)\r\n        at com.github.benmanes.caffeine.cache.NonReentrantLock.lock(NonReentrantLock.java:78)\r\n        at com.github.benmanes.caffeine.cache.BoundedLocalCache.performCleanUp(BoundedLocalCache.java:1096)\r\n        at com.github.benmanes.caffeine.cache.BoundedLocalCache.afterWrite(BoundedLocalCache.java:1017)\r\n        at com.github.benmanes.caffeine.cache.BoundedLocalCache.put(BoundedLocalCache.java:1655)\r\n        at com.github.benmanes.caffeine.cache.BoundedLocalCache.put(BoundedLocalCache.java:1602)\r\n        at com.github.benmanes.caffeine.cache.LocalManualCache.put(LocalManualCache.java:64)\r\n```\r\n\r\nLooking at the code, I can't imagine a scenario this could occur, but it _does_ occur under heavy load of our JVMs.\r\n\r\nAny ideas what we could do? For now, as a workaround, I've added a synchronized() block around the cache.put() methods to make sure only 1 thread is adding new values to the cache at a time."},"comment":{"url":"https://api.github.com/repos/ben-manes/caffeine/issues/comments/346505746","html_url":"https://github.com/ben-manes/caffeine/issues/203#issuecomment-346505746","issue_url":"https://api.github.com/repos/ben-manes/caffeine/issues/203","id":346505746,"user":{"login":"ben-manes","id":378614,"avatar_url":"https://avatars3.githubusercontent.com/u/378614?v=4","gravatar_id":"","url":"https://api.github.com/users/ben-manes","html_url":"https://github.com/ben-manes","followers_url":"https://api.github.com/users/ben-manes/followers","following_url":"https://api.github.com/users/ben-manes/following{/other_user}","gists_url":"https://api.github.com/users/ben-manes/gists{/gist_id}","starred_url":"https://api.github.com/users/ben-manes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ben-manes/subscriptions","organizations_url":"https://api.github.com/users/ben-manes/orgs","repos_url":"https://api.github.com/users/ben-manes/repos","events_url":"https://api.github.com/users/ben-manes/events{/privacy}","received_events_url":"https://api.github.com/users/ben-manes/received_events","type":"User","site_admin":false},"created_at":"2017-11-23T00:08:31Z","updated_at":"2017-11-23T00:08:31Z","author_association":"OWNER","body":"It would also be helpful if you track the cache stats. Then we could know for certain that eviction halted. Otherwise my testing only shows threads backed up, but progress continues. If I add a shutdown hook, then they all quickly complete normally. I cannot reproduce any hanging."}}
{"actor":{"display_login":"ben-manes"}}