feat(core): ✨ add opt-in CAS retry and unify Option interface#164
Merged
justapithecus merged 2 commits intomainfrom Mar 8, 2026
Merged
feat(core): ✨ add opt-in CAS retry and unify Option interface#164justapithecus merged 2 commits intomainfrom
justapithecus merged 2 commits intomainfrom
Conversation
Introduce bounded automatic retry on ErrSnapshotConflict for both Dataset and Volume write paths. Data files are written once; on conflict only the manifest is re-parented and the pointer CAS retried. Unify the Option system: Volume now accepts the same Option interface as Dataset (applyVolume added). WithVolumeChecksum and VolumeOption type removed; WithChecksum works for both Dataset and Volume. - Add WithRetryCount, WithRetryBaseDelay, WithRetryMaxDelay, WithRetryJitter - Single retryOption type with closure to eliminate boilerplate - Extract commitWithRetry helper shared by Write, StreamWriteRecords, and StreamWriter.Commit - Volume.Commit re-merges blocks against refreshed parent on retry; ErrOverlappingBlocks terminates immediately (non-retryable) - Add ErrOptionNotValidForVolume sentinel - Update contracts and PUBLIC_API.md Closes #163 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
commitWithRetry was generating a new snapshotID on each retry attempt, but data files were already written under paths derived from the original ID. After retry, the manifest would advertise the new ID while FileRef paths pointed to the old snapshot directory, breaking layout co-location. Fix: keep the same snapshotID across retries. On CAS failure, no manifest was written for this ID (pointer is written before manifest), so the namespace is safe to reuse. Only the parent ID and pointer CAS change. Also fixes CONTRACT_VOLUME.md code example that still showed the removed VolumeOption type in the NewVolume signature. - Add path-consistency assertion to retry test - Update contract docs to say "same snapshot ID" not "new snapshot ID" Co-Authored-By: Claude Opus 4.6 <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.
Summary
Add bounded automatic retry on
ErrSnapshotConflictfor both Dataset and Volume write paths, and unify theOptioninterface soNewVolumeaccepts the same option type asNewDataset.Highlights
WithRetryCount(n)enables opt-in CAS retry on commit conflict — data files are written once, only the manifest re-parent and pointer CAS are retriedOptioninterface —applyVolumemethod added;VolumeOptiontype andWithVolumeChecksumremoved;WithChecksumnow works for both Dataset and VolumeWithRetryBaseDelay,WithRetryMaxDelay,WithRetryJitter— full backoff customization with sensible defaults (10ms base, 2s cap, full jitter)retryOptiontype with closure pattern eliminates per-option boilerplate (one struct, three methods, four constructors)commitWithRetryhelper shared byWrite,StreamWriteRecords, andStreamWriter.Commit— no retry code duplicationCommitre-merges blocks against the refreshed parent on each retry;ErrOverlappingBlocksterminates immediately (non-retryable)Breaking Changes
VolumeOptiontype removed —NewVolumenow accepts...OptionWithVolumeChecksumremoved — useWithChecksum(same function, now works for both)Test plan
retry_test.go)WithRetryCount(0)preserves current behavior (immediateErrSnapshotConflict)ErrOptionNotValidForDatasetReader)WithRetryCount(0)preserves current behaviorErrOverlappingBlocksWithChecksumworks for VolumeNewVolume(ErrOptionNotValidForVolume)Closes #163
🤖 Generated with Claude Code