News for hackers. Stuff that matters.
Re:Cache made consistent: Meta’s cache invalidation solution by uvdn7 on Saturday June 11, 2022 @09:17PM (#31710301)
Re:Cache made consistent: Meta’s cache invalidation solution by yencabulator on Sunday June 12, 2022 @12:09PM (#31715580)
From the article:

  - client starts a transaction
  - client runs any mutations as needed
  - client collects user_ids whose cache entries need to be invalidated
  - client invalidates cache
  - client commits the transaction
You can now have caches fetching & storing the "old" state between the last two steps. This fails to invalidate cache in all scenarios.
Re:Cache made consistent: Meta’s cache invalidation solution by uvdn7 on Sunday June 12, 2022 @05:08PM (#31718287)
Good catch! I shouldn't have omitted the details here. Roughly there are two ways to solve the race you mentioned here.

You can use a versioning scheme supported by the database to do compare-and-swap – i.e. sending invalidate along with a hybrid-logical-clock. HLC is nice in this case as it handles DB transaction rollback gracefully, if the database supports it.

Or we can always do the invalidation asynchronously (by recording the invalidation keys transactionally and have a tailer that sends out the invalidation).

I will make an edit to the blog to make it more clear. Let me know if that makes sense!

I mean this – cache invalidate/fill race specifically – is very much a solved problem from a protocol perspective, as long as our definition of the problem is the same – do not leave stale data in cache indefinitely. That is not to say it is easy; I am not trying to minimize anyone's struggles. https://research.facebook.com/publications/scaling-memcache-... might be of interest.

A lot of the challenges in cache are in making the tradeoffs between consistency and coordination overhead based on the workload and the requirement, _and actually_ making caches consistent in production. As explained in the post, there are practical challenges that are very unique to cache and cache invalidation.

Re:Cache made consistent: Meta’s cache invalidation solution by gigatexal on Sunday June 12, 2022 @02:46PM (#31717117)
So they didn't solve one of the fundamentally difficult things related to computing. I knew it was probably good to be dubious of such claims.
Re:Cache made consistent: Meta’s cache invalidation solution by uvdn7 on Monday June 13, 2022 @09:08AM (#31725015)
I will not say cache invalidation is easy; and I am not trying to minimize anyone’s struggles. But cache invalidation is _not_ like FLP impossibility or CAP. Too many systems reason caching (inherently a distributed system) in an ad-hoc way that leads to failures and this belief that cache invalidation is uniquely hard (https://twitter.com/marcjbrooker/status/1534944338341310470?...).

https://en.wikipedia.org/wiki/Consensus_(computer_science)

https://en.wikipedia.org/wiki/CAP_theorem