New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LocalLoadingCache.getAll
deadlock
#771
Comments
For those cases of long computations, the recommendation is to decoupling that work from the hash table's operation. This could be done by using I think the actual problem in #506 was discovered later #203 (comment) that those users had a StackOverflowError which caused the locks to be left in corrupted state (JEP 270). |
thanks for the reply. But I do not understand why the Does BTW, I think my initial conclusion is wrong, this is not a deadlock, but a thread contention. |
The cache internally uses If the cache's maximum size is tiny then you might also be hitting excessive contention because the number of locks depends on the map's size. This is generally okay because when the map resizes to grow more locks are added, but a small cache would cap the growth. You can set a larger initial capacity so that |
Any updates? |
so sorry for the late reply. I've been so busy these days. Anyway, thanks a lot for your reply. It really helps me. 👍👍👍 |
Thanks for the update! You might find |
Sorry to comment again, but I eventually found that this retention was caused by the same cache's nested load method. It's hard to figure out because the code is kind of complicated. I've seen this guava issue raised by you to solve the deadlock problem: guava issue, and it's still open, so both |
Caffeine relies on ConcurrentHashMap's fail fast detection. That should cover everything as of Jdk12, but previous releases had gaps and in jdk8 it simply live-locked. If you observe any in a later release then that is a new bug. Unfortunately I doubt this was backported if you are on an older jdk. |
Thanks. It seems that we have to detect the nested call by ourselves to avoid this kind of problem. It's easy to avoid when we are coding but hard when dealing with legacy codes. Besides, updating to a newer JDK version is also a big challenge.😂 |
yeah, sorry it is so troublesome. I actually did catch it during the pre-Java 8 code review (2011), but unfortunately it wasn't fixed until I rediscovered it again (2014). You can kind of work around it using AsyncCache faq but in an annoying, brittle way. Unfortunately tying the compute to the hash table means an addition triggering a resize can corrupt it (the |
Hi, I have some new findings today, when we try to move to I found that |
Caffeine can behave similarly, per the faq. In that factorial example, the computation is decoupled from the hash table and memoization is achieved by using a Guava forked Java 5's |
hi there, our service is using caffeine as cache, recently some of the service pod met the deadlock.
As the jstack log provided bellow, all the other
LocalLoadingCache.getAll
thread were blocked by this thread.I'm using version 2.6.2.
I've seen the issue here: #506, but it seems a little different from my issue.
So I wonder is this a bug of this old version, or is this caused by our own code?
Thanks in advance~
The text was updated successfully, but these errors were encountered: