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

Apparent Cache.refresh race condition #1211

Closed
gissuebot opened this issue Oct 31, 2014 · 6 comments
Closed

Apparent Cache.refresh race condition #1211

gissuebot opened this issue Oct 31, 2014 · 6 comments
Assignees
Labels
Milestone

Comments

@gissuebot
Copy link

Original issue created by lowasser@google.com on 2012-11-23 at 01:37 AM


http://stackoverflow.com/q/13521523/869736

If I understand what's going on correctly, the issue is that in between the steps

  1. Check that the entry is eligible for refresh, according to its last write time.
  2. Acquire the segment lock.
  3. Check that the entry isn't still loading.
  4. Schedule a refresh.

can interleave badly with the end of a refresh:

A. Finish the refresh future.
B. Acquire the segment lock.
C. Set the value, using a StrongValueReference instead of a LoadingValueReference.
D. Update the write time.
E. Release the lock.

In particular, what can happen is that if a get happens just as the entry is done refreshing, the steps can interleave

A, B, 1, C, D, E, 2, 3, 4

in which case a refresh will get inappropriately scheduled: it will see that the write time was long enough ago that a refresh is appropriate, and then it will see that the entry has a StrongValueReference and is not currently loading, so it will start a refresh immediately after the previous refresh completed.

@gissuebot
Copy link
Author

Original comment posted by lowasser@google.com on 2012-12-07 at 11:32 PM


(No comment entered for this change.)

@gissuebot
Copy link
Author

Original comment posted by j.e.frank on 2013-01-23 at 10:16 PM


I ran into this same issue, with a cache that I am hitting hard at the time that a refreshAfterWrite is triggered. It ends up doing reload twice.

@gissuebot
Copy link
Author

Original comment posted by wasserman.louis on 2013-01-23 at 10:18 PM


Are you hitting this issue with the 14.0-rc?? releases? This should have been fixed by 7508583


Status: Fixed

@gissuebot
Copy link
Author

Original comment posted by wasserman.louis on 2013-01-23 at 10:20 PM


(No comment entered for this change.)


Labels: Milestone-Release14

@gissuebot
Copy link
Author

Original comment posted by j.e.frank on 2013-01-23 at 10:29 PM


Sorry, I didn't notice this issue was listed in the v14 release (I was just looking at its status here, which I see has now been changed to Fixed). No, I'm using 13.0.1. I'm evaluating Guava Cache as a replacement for Ehcache in a particular application. It's high profile (relatively speaking, for me) so I'm sticking with stable releases for now.

@gissuebot
Copy link
Author

Original comment posted by wasserman.louis on 2013-01-23 at 10:38 PM


The 14.0 release should be happening relatively soon, FYI.

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

No branches or pull requests

3 participants