An issue in with Timeouts / Response Listener #1024
Replies: 1 comment 2 replies
-
Thanks for trying to explain the problem.
If possible then I'd recommend using 3.x. Java 8 itself reached end-of-life for active support over a year ago, with on-going support for security fixes until 2030. Similarly this project supports 2.x releases, but does not actively backport or make fixes unless impacting a 2.x user. Thus, 2.x is not actively developed and there is always a chance that 3.x contains a fix that would have avoided your problems.
In your case of a fixed duration of 1 minute for create or update, this matches
Could you show how you added to the cache? For example
Yes, that could occur if you have expensive functions that run to compute the value or on eviction.
The cache tries to behave in a linearizable manner, so it is hard to tell. If the expiration lost a race with the update then the eviction would attempt would fail as it detected that the entry was no longer eligible and the listener would not be invoked. Once the removal listener is called the entry was already discarded from the mapping, so 5-6 look like they are in-order.
The removal listener is called asynchronously after the map operation completed, which means it does not block other cache operations but could be run out-of-order with other updates. The eviction listener is called synchronously within map's compute method that is discarding the entry, so it is blocking and receives change in key order. Ideally neither should write back to the cache, but the removal listener could do so safely while the eviction listener would violate the map contract. That distinction can be useful if trying to synchronize with some secondary state where out-of-order operations would cause mayhem. |
Beta Was this translation helpful? Give feedback.
-
Hi All - Sorry for what is likely to be a bit of a ramble but I will try my best to explain the issue I had yesterday as clearly as possible
So - I have been using Caffeine cache (2.9.3) to create an application that expires some keys (and their associated values) when the key has not been updated within a certain window (1 minute)
My code for this looks roughly as follows
This has been working perfectly in test and production when only one producer is present. Yesterday, unfortunately we had a scenario where we had 2 producers so updates occurred a little more frequently (all be it marginally so i am not sure if this is the actual cause)
To note below - when I say 19 different key value pairs - it is always the same keys, just different value objects (these value objects have created time hence I know how to link the timeout occurrence to the insert)
The timing of events went like this;
I really am not sure why the behaviour did this but here are some initial thoughts / questions I have and maybe someone maybe able to tell me where I am wrong / offer some advise please?
Anyway - sorry for the long ramble and thank you very much for reading - I hope it made sense! I am trying my best to reproduce this behaviour but am unable to :(
Kind regards
Beta Was this translation helpful? Give feedback.
All reactions