-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Compute cache value on calling thread to fix thread starvation #13244
Compute cache value on calling thread to fix thread starvation #13244
Conversation
I'm making this a WIP until tomorrow. The |
c66e3f6
to
c84660e
Compare
All cache values computations are now done on the calling thread in a synchronous way. This means the cache extension no longer needs context propagation, so I removed the I also removed some code that was used to prevent Caffeine from logging warning messages when an exception was raised during an async cache value computation. It was no longer needed since there's no async computation anymore. This PR is ready for a review. |
@gsmet Assuming the PR is merged with the current code, it may be worth mentioning in the release note that the cache extension no longer needs the context propagation extension. |
c84660e
to
1f48f99
Compare
Last minute push: since |
@gwenneg I wonder if we should backport this to 1.10? It looks safe enough and fixes an annoying issue. WDYT? |
@gsmet Yes, I think this should be backported not only because of the thread starvation fix but also because this new version should be much better in terms of performances. |
1f48f99
to
72ea4e8
Compare
Commit message changed to better reflect the PR content. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick turnaround!
Thanks @ben-manes for your help with this! |
If the loader throws an exception, does it complete the future? It doesn’t appear to, which would cause the in-flight future to remain in the cache and block subsequent readers. I might be misreading but can you please verify? |
There was indeed an issue with exception handling that was fixed in #13410. |
oh! I forgot about that, thanks! |
Thanks for alerting me here! |
Partiallyfixes #13158.Deadlock should no longer happen
when the, the cache value computation is now done synchronously from the calling thread.lock timeout
feature from the cache extension is not used. In that specific case which is probably the most common way to use the extensionDeadlock can still happen while using both thelock timeout
feature and the context propagation extension.This was tested using JMeter and the reproducer provided by @sivelli. I reproduced the issue locally with
1.9.2.Final
and it's gone with this PR.