Paths Subjects Questions Quizzes Pricing Search
Advanced Open Pro

Diagnosing a Stale-Read Race Condition

Your team uses cache-aside reads. On a database write, the application does: db.update(product) ; cache.set(key, new_value) (it sets the new value into the cache rather than deleting the key). Users occasionally report seeing an old price for a few minutes after a price change, even though the write itself succeeded and the TTL is one hour.

  1. Construct a concrete interleaving of two concurrent requests that explains the bug.
  2. Explain why switching from cache.set(...) to cache.delete(key) on write fixes this specific bug.
  3. Does deleting instead of setting introduce any new problem? What would you tell the interviewer about the trade-off?

Share this question

← Back to Caching Strategies practice

We use cookies for product analytics to improve OmniAtlas. See our Privacy Policy.