dnrajugade / guava-libraries

Automatically exported from code.google.com/p/guava-libraries
Apache License 2.0
0 stars 0 forks source link

Apparent Cache.refresh race condition #1211

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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.

Original issue reported on code.google.com by lowas...@google.com on 23 Nov 2012 at 1:37

GoogleCodeExporter commented 9 years ago

Original comment by lowas...@google.com on 7 Dec 2012 at 11:32

GoogleCodeExporter commented 9 years ago
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.

Original comment by j.e.fr...@gmail.com on 23 Jan 2013 at 10:16

GoogleCodeExporter commented 9 years ago
Are you hitting this issue with the 14.0-rc?? releases?  This should have been 
fixed by 
https://code.google.com/p/guava-libraries/source/detail?r=75085833f67d07b9dcc071
e0703cb1027e6c0b28.

Original comment by wasserman.louis on 23 Jan 2013 at 10:18

GoogleCodeExporter commented 9 years ago

Original comment by wasserman.louis on 23 Jan 2013 at 10:20

GoogleCodeExporter commented 9 years ago
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.

Original comment by j.e.fr...@gmail.com on 23 Jan 2013 at 10:29

GoogleCodeExporter commented 9 years ago
The 14.0 release should be happening relatively soon, FYI.

Original comment by wasserman.louis on 23 Jan 2013 at 10:38

GoogleCodeExporter commented 9 years ago
This issue has been migrated to GitHub.

It can be found at https://github.com/google/guava/issues/<id>

Original comment by cgdecker@google.com on 1 Nov 2014 at 4:13

GoogleCodeExporter commented 9 years ago

Original comment by cgdecker@google.com on 3 Nov 2014 at 9:08