-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Low level cache failure for sync/reactive/future Cacheable get is not handled by CacheErrorHandler #21590
Comments
I have the same problem in spring v4.3.13 |
and the same problem in Spring ver. 5.1.6 |
Things aren't as easy to implement I am afraid. The purpose of the listener is to determine if the exception should bubble up the stack or if we should always call the underlying method and ignore it. With a sync call, the cache library is responsible to check its internal state and call the underlying method if necessary (and sync other threads attempting to lookup the same value). If we call the error handler on get and your custom implementation decides to ignore it, then we should call the method and the value will not be stored in the cache. So the next thread waiting for that key (potentially) is likely to call the method again if the cache hadn't recover. There is also the odd situation that we rely on All in all, we are less in control and less likely to provide the right semantics. I've pushed some initial work that calls the error handler in such case, flagging for team attention to see what the rest of the team thinks. |
same problem in 5.2.1 I'm using error handler to ignore scenarios where Redis is unavailable. Is there a recommended workaround for sync=true and handling get errors? |
I would like to use an error handler to invalidate cache on deserialization exception during a new deployment even though Cacheable has sync=true attribute.
|
A lot of digging until I discovered that it's |
TLDR: Unfortunately, I do not have any workaround for that. I used to tear down and spin up again whole cluster whenever we introduce any incompatible cache item that cause HazelcastSerializationException. :-/ I know I could contribute to this cool open source project, but I have not done so on this issue yet. |
This seems like a reasonable fix for this issue. Are there any downsides of this approach? I was looking into this and realised I would've ended up making something very similar to this same fix. Happy to roll this into a PR with the above additionals, if there's interest, and consideration, and some buy-in from the team on this fix. The downside of not having such a fix is that every caller of the Cacheable would need to have its own error handling mechanism to catch such a scenario, which would likely be to attempt to make the same call. |
Is there any update on this one? It seems like a pretty common use case to ignore cache failures and continue with the method call, but that is currently not possible with sync=true setting. The only workaround I've found while still using Cacheable annotation is to set sync=false, but that is also not ideal from performance perspective. I understand that the sync=true would not be honored if the cache is down, but that is fine from my perspective. The purpose of sync=true in my use case is that when the cache is up it should wait for the value. If the cache is down I'm perfectly fine with all the method calls going through in parallel. |
Jens Wilke opened SPR-17052 and commented
Code from
CacheAspectSupport
:@Cachable(sync=true)
CacheErrorHandler
is not visited.CacheInterceptor.invoke
Affects: 5.0.7
The text was updated successfully, but these errors were encountered: