Conversation
Replaces the placeholder MetadataStore.Update (which delegated the entire read-modify-write to the fallback datastore) with a wrapper-level CAS retry loop that always lands writes in primary. When the doc is in primary or the doc is absent from both stores, it delegates to primary.Update; when the doc lives only in fallback, it feeds the fallback value to the caller's callback and inserts the result into primary via WriteCas, retrying on CAS race. A delete returned by the callback for a fallback-only doc is a no-op in primary - the metadata migration sweep tombstones the fallback copy. WriteUpdateWithXattrs gets the same dual-read pattern for symmetry (callers today are application-data only, but a future metadata caller would otherwise silently skip fallback data). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
CBG-5291
MetadataStore.Updatepreviously delegated the entire read-modify-write to the fallback datastoreImplements a
MetadataStorewrapper-level CAS retry loop that always writes to primary, even when the doc lives only in the fallback store.MetadataStore.WriteUpdateWithXattrsisDeletefor fallback-only doc (no-op — migration sweep handles cleanup), post-SetMigrationCompletebehaviour, and the xattr analogue of the migration case.Why this is CAS-safe
The wrapper invariant — no writes ever go to fallback while the dual-store is in use — means the only writer to either store is this wrapper writing to primary. So the loop:
primary.Exists. If found (or migration is sealed), delegate toprimary.Update/primary.WriteUpdateWithXattrs— those already have correct CAS retry loops.WriteCas/WriteWithXattrswithcas=0(insert) into primary.IsCasMismatch(covers bothgocb.ErrDocumentExistsand rosmarCasMismatchErr), retry from step 1 — by now primary holds the doc, so we go through the standard primary CAS path.Integration Tests