-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
expiresVariable() leaves a scheduled expiry even when the cache is empty #542
Comments
It wouldn't be intended, but could be a side effect of the timer wheel being so optimized that it is hard to debug and test, causing mistakes to slip through. I think we'd need to get a test failure and then debug where the logic went wrong. There is a related discussion in #541 that could hint towards some bugs in the calculation logic. |
gah, i think this is a simple mistake...i don't have i've noticed something else though, if i explicitly empty the cache (eg |
That's true, I was thinking of that as well. I wasn't sure if it was worth mentioning because future usages would add to the cache and cause the pacer to reschedule, canceling the last future. Or, if that task comes up, the cleanup would be instant as no work to do. I think it's smart to add that extra optimization to to |
i'm not sure. perhaps having it on |
I think the attached following patch might be the right improvement then. If the cache is emptied out by any means it should cancel the future, so that would be during maintenance or clear, which doesn't need to call maintenance by wiping everything out directly. Some added tests would be needed for the merge, so I'll tidy that up later. |
ok cheers. i don't suppose u could backport this to a 2.9.1? :) |
btw thanks for your prompt responses. i've managed to workaround it on 2.9.0 with some hackery (poking methods that i shouldn't). |
That's great, I'm glad it is not a blocker. When I have the time then I'll integrate and backport to 2.x. |
When the timer wheel advances then higher level buckets evict to the lower wheels. In some cases this reorganization failed, such as when the nano time transitioned from a negative to a postive clock value. The number of steps to turn the wheel is now determined by a more accurate calculation. (fixes #541) When a scheduler is enabled then a future task may exist against the next expiration event to perform cache maintenance. If the cache becomes empty beforehand, e.g. Map.clear(), then this future can be canceled. (fixes #542)
When the timer wheel advances then higher level buckets evict to the lower wheels. In some cases this reorganization failed, such as when the nano time transitioned from a negative to a postive clock value. The number of steps to turn the wheel is now determined by a more accurate calculation. (fixes #541) When a scheduler is enabled then a future task may exist against the next expiration event to perform cache maintenance. If the cache becomes empty beforehand, e.g. Map.clear(), then this future can be canceled. (fixes #542)
Released in 2.9.1 and 3.0.2 |
i'm having a bit of trouble reproducing this in a test case, so i'll ask a question to see whether it's intended behaviour.
basic background, we're on JDK8 so i have to use a
ScheduledExecutorService
for thescheduler()
. i don't want this to keep the JVM running so i have given it acorePoolSize
of 0. i'm using variableExpiry, and the behaviour i'm seeing is that after the last (and in this particular instance, only) entry in the cache has expired out, the cache is leaving a scheduled PerformCleanup task for about 155m in the future. none of my expiry times has ever been anywhere near this value (it's either MAX_EXPIRY (about 150y)), or about 10 seconds after its last update.is this intended behaviour? i haven't worked out exactly where it's getting this interval from (except that obviously it comes from the
timerWheel
).The text was updated successfully, but these errors were encountered: