Hi,
Suppose there's a transactional cache in front of a database that holds current state of some of the records to speed up data reads. What would be a good way to fix the following race condition:
Thread T1 is about to update record R in DB, it isn't initially cached; at the same time T2 tries to read it, gets cache miss, reads R from DB and caches stale value. Step by step:
T1 is about to update R
T2 tries to read R and gets cache miss
T2 reads R from DB
T1 changes R in DB
T1 invalidates (or updates) R in cache
T1 commits
T2 puts old R in cache
Result: cache contains stale data.
-
caching race condition (0 messages)
- Posted by: Konstantin Sobolev
- Posted on: March 22 2010 19:02 EDT