Skip to content
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

Deadlock when BoundedLocalCache.scheduleDrainBuffers throws an exception #130

Closed
tepitebson opened this issue Nov 4, 2016 · 3 comments
Closed

Comments

@tepitebson
Copy link

Used version: 2.3.2
In an error situation, we noticed a deadlock during call to cache's get method. We have no clear stacks to show the actual deadlock, but according to the log, an OutOfMemoryError was catched by BoundedLocalCache.scheduleDrainBuffers().

It seems that if no executor is defined for the cache it uses ForkJoinPool and with ForkJoinPool, cache's evictionLock is a NonReentrantLock which by its documentation will deadlock if called recursively.

If scheduleDrainBuffers throws an exception, performCleanup is called inside the catch-block while still holding the evictionLock. And since the performCleanup calls evictionLock.lock() on its first line, it seems that a deadlock is unavoidable in this scenario?

@ben-manes
Copy link
Owner

Thanks for the investigative work! You're absolutely correct that I forgot about this scenario. I must have only considered reentrancy if the executor threw a RejectedExecutionException which FJP does not (BoundedLocalCacheTest#evict_rejected). The fix seems straightforward so I'll have a release over the weekend.

In the mean time, as I am sure you know, you can use a non-FJP executor or even ForkJoinPool.commonPool()::execute to force a reentrant lock.

@ben-manes
Copy link
Owner

I plan on releasing this tomorrow and will update you when its published. Thanks again for reporting and debugging the issue.

ben-manes referenced this issue Nov 6, 2016
HuntBugs is the unofficial successor to Findbugs on a clean code base.
The remaining warnings are all false positives and not sure how to
suppress individually. It did find a few mistakes where the array was
checked for null, rather than its element (weak key null guard).

See https://github.com/amaembo/huntbugs for details.
@ben-manes
Copy link
Owner

Released 2.3.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants