-
Notifications
You must be signed in to change notification settings - Fork 138
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-4289 fix import CV value for HLV code #7146
base: release/anemone
Are you sure you want to change the base?
Conversation
- remove _sync.ImportCAS (CBG-4285) - don't update HLV if mutation comes from XDCR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionally looks ok, some suggestions for clarity on the comments/conditions.
// Set ImportCAS to the previous document CAS, but don't otherwise modify HLV | ||
d.HLV.ImportCAS = d.Cas | ||
} else { | ||
// Update HLV if: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the description as you've got it muddies the rationale behind the decision making here (simply that we want to update the HLV only if the current document cas isn't already accounted for in the HLV + mou).
// Update HLV if: | |
// Do not update HLV if the current document version (cas) is already included in the existing HLV, | |
// as either: | |
// 1. _vv.cvCAS == document.cas (current mutation is already present as cv), or | |
// 2. _mou.cas == document.cas (current mutation is already present as cv, and was imported on a different cluster) |
// - document was written by another cluster, itself having an undergone an import | ||
// - _vv.cvCAS == document cas and _mou.cas != document cas | ||
|
||
if !hasHLV || (d.HLV.CurrentVersionCAS != d.Cas && (previousMou == nil || base.HexCasToUint64(previousMou.CAS) != d.Cas)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this can be rewritten to match the comment suggestion I think that would be more readable. Even something like this maybe:
cvCASMatch := hasHLV && d.HLV.CurrentVersionCAS == d.Cas
mouMatch := previousMou != nil && base.HexCasToUint64(previousMou.CAS) == d.Cas)
if !cvCASMatch && !mouMatch {
Created new tests to cover import cases https://docs.google.com/document/d/19mC9-TptN7ynuF5XR9TQ_MckHWsSrjUfI2p71G_DD1U/edit#heading=h.xzdilbaiwy25
The specific bugs initially noticed were around
_vv.ver
getting updated tonewVVEntry.Value = expandMacroCASValueUint64
which was never correct on import. Additional logic was expanded to cover all tests.For ease of reading this code, the existing tests were ported to a parameterized test first with the buggy logic in place, you can read the commit separately.
Some tests are disabled are set to fix at a future time https://jira.issues.couchbase.com/browse/CBG-4292. Before working on that ticket, https://jira.issues.couchbase.com/browse/CBG-4291 should be fixed on main and rebased onto anemone.
Code is also tested with live XDCR.
Also removes
ImportCAS
as part of CBG-4285.Pre-review checklist
fmt.Print
,log.Print
, ...)base.UD(docID)
,base.MD(dbName)
)docs/api
Integration Tests
GSI=true,xattrs=true
https://jenkins.sgwdev.com/job/SyncGateway-Integration/2746/