Repository navigation
feat(client): add Merged conflict resolution result that stays conditional - #582
Merged
Merged
Conversation
…ional ConflictResolutionResult.Client force-writes with no If-Match header, which can silently overwrite a concurrent update when the resolver merged the entity from the server row. Add ConflictResolutionResult.Merged, which sends If-Match with the server entity version the resolver saw, re-resolves on a further conflict (up to 5 attempts), and documents that Client is an unconditional overwrite. Fixes CommunityToolkit#579
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
Fixes #579.
When an
IConflictResolverreturnedConflictResolutionResult.Client, the forced re-send had noIf-Matchheader. That is correct for a plain "client wins" policy, but it is unsafe for a merge resolver. A merged entity is computed from the server row in the 409/412 response, so any write that lands before the forcedPUTis silently overwritten.Changes
ConflictResolutionResult.Merged. The re-send is conditional: it sendsIf-Matchwith the version of the server entity that the resolver received.Failed.Mergedresult cannot be made conditional. The operation is left asFailedrather than silently falling back to a force write.Clientbehaviour is unchanged (a true force write), so existing users are unaffected. Its XML docs now say it is an unconditional overwrite.docs/in-depth/client/index.md) describe every result value and warn thatClientis not safe for merges. The custom-resolver example now returnsMerged.Tests
New tests in
ConflictResolver_Tests:Clientstill sends noIf-Match.MergedsendsIf-Matchwith the server version.Mergedre-resolves when the server changes again.Mergedfails after the maximum number of attempts.Mergedfails when the server entity has no version.The full client test suite passes locally (1440 tests).
build-library.ymlandbuild-docs.ymlpass on the fork. One earlier library run failed on an unrelated threading test,QueueHandler_WithThreads_EnqueueRange(nThreads: 8), and passed on re-run.