Add more robust cache invalidation to CachingBucket #9575
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does
This change makes use of
add
operations for special "lock" cache entries to ensure that when items in object storage are mutated, stale results are not immediately stored to cache again.It does this by
set
ing "lock" cache entries with a short TTL when an item in object storage is about to be mutated. This prevents reads of the item from caching the results afterwards. After the item is mutated in object storage, its cache entries (excluding the lock entries) are deleted. After the lock entries expire, reads of the item are allowed to store results in the cache again.Which issue(s) this PR fixes or relates to
Part of #9386
Follow up to #9387
Notes for reviewers
At a high level the way this works is:
CachingBucket.Upload
starts a mutation operation on some item in object storage and special "lock" keys get set in Memcached with a short (15s
) TTL.CachingBucket.Upload
completes the mutation operation on the object storage item.CachingBucket.Upload
deletes any cache entries associated with the item (contents, exists, attributes), but not the lockCachingBucket.Get
that attempt to cache the item that has just been modified will short-circuit for the next15s
because they cannot successfullyMemcached.Add()
the lock key.CachingBucket.Get
will be able to cache the item again.Checklist
CHANGELOG.md
updated - the order of entries should be[CHANGE]
,[FEATURE]
,[ENHANCEMENT]
,[BUGFIX]
.about-versioning.md
updated with experimental features.