Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CBG-4365 rosmar xdcr, use _mou.cas for conflict resolution #7206

Merged
merged 4 commits into from
Nov 25, 2024

Conversation

torcolvin
Copy link
Collaborator

CBG-4365 rosmar xdcr, use _mou.cas for conflict resolution

I ran topologytests without a skip on TestHLVUpdateDocumentSingleActor and they now intermittently pass, rather than consistently fail without this patch.

The guts of this ticket are to consider the cas for conflict resolution in xdcr as actual cas, unless _mou.cas == doc cas, in which case, using _hlv.cvCas is correct. This matches the behavior of server XDCR.

MetadataOnlyUpdate is one of the only datastructures that we have that stores cas as a string, and that's fine for serialization but problematic for comparison. I decided to write method to convert the data rather than writing yet more comparisons in xdcr code. I don't think it makes sense to change the data on marshal and unmarshal due to the use of string comparison in computeMetadataOnlyUpdate but maybe having it convert all the values to hex on marshal/unmarshal would make more sense.

Pre-review checklist

  • Removed debug logging (fmt.Print, log.Print, ...)
  • Logging sensitive data? Make sure it's tagged (e.g. base.UD(docID), base.MD(dbName))
  • Updated relevant information in the API specifications (such as endpoint descriptions, schemas, ...) in docs/api

Integration Tests

@@ -373,3 +388,21 @@ func updateHLV(xattrs map[string][]byte, sourceHLV *db.HybridLogicalVector, sour
}
return nil
}

// getConflictResolutionCas returns cas for conflict resolution. If thethe conflict resolution cas.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo here? I think it would be good to include on the comment the expected interaction between actual cas and mou cas, something like the below:
If we have:

  • the _mou.cas == actualCas we will return _vv.cvCAS for conflict resolution,
  • if mou.Cas is out of date we will use _vv.ver
  • if mou.Cas is not out of date but there is no HLV we return 0 to match XDCR

@@ -342,21 +350,24 @@ func getHLVAndMou(xattrs map[string][]byte) (*db.HybridLogicalVector, *db.Metada
return hlv, mou, nil
}

func updateHLV(xattrs map[string][]byte, sourceHLV *db.HybridLogicalVector, sourceMou *db.MetadataOnlyUpdate, sourceID string, sourceCas uint64) error {
func updateHLV(xattrs map[string][]byte, sourceHLV *db.HybridLogicalVector, sourceMou *db.MetadataOnlyUpdate, sourceID string, copiedCas uint64) error {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what 'copiedCas' implies here (as opposed to source cas) - maybe a comment to explain?

@torcolvin torcolvin enabled auto-merge (squash) November 25, 2024 20:47
@torcolvin torcolvin merged commit fce1035 into release/anemone Nov 25, 2024
35 of 36 checks passed
@torcolvin torcolvin deleted the CBG-4365 branch November 25, 2024 23:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants