-
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-4300 improve rosmar XDCR handling #7162
base: release/anemone
Are you sure you want to change the base?
Conversation
torcolvin
commented
Oct 18, 2024
- copy HLV if set on from collection, and construct HLV if needed
- check _mou.pCAS when deciding whether to XDCR document
- copy HLV if set on from collection, and construct HLV if needed - check _mou.pCAS when deciding whether to XDCR document
@@ -123,7 +123,46 @@ func (r *rosmarManager) processEvent(ctx context.Context, event sgbucket.FeedEve | |||
return true | |||
} | |||
|
|||
err = opWithMeta(ctx, col, r.fromBucketSourceID, toCas, toXattrs, event) | |||
hlv, mou, body, err := getBodyHLVAndMou(event) |
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.
When mou.cas == cas on the target (i.e. there was an import), I believe we should be using toCas = hlv.cvCAS to decide whether to replicate the source mutation. So I think we require something above line 120 like:
if toXattrs.mou.cas == toCas {
toCas = toXattrs.hlv.cvCAS
}
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'm wondering if naming everything 'sourceHLV, sourceMou, sourceBody' and 'targetHLV, targetMou etc' will make it easier to follow the logic here.
} | ||
if hlv != nil && mou != nil { | ||
pCAS := base.HexCasToUint64(mou.PreviousCAS) | ||
if pCAS <= toCas { |
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.
We shouldn't be considering pCAS when deciding whether to replicate or not - I believe only mou.cas, cvCAS and cas should be considered.
hlv = &newHlv | ||
err := hlv.AddVersion(db.Version{ | ||
SourceID: r.fromBucketSourceID, | ||
Value: event.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.
Here's where we want to use pCAS. If the source mutation (event) was an import (event.Cas == mou.cas), we should set the value to event.mou.pCas.
r.errorCount.Add(1) | ||
return false | ||
} | ||
hlv.CurrentVersionCAS = event.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.
Similar to the comment above, if the source mutation was an import, should set cvCAS to pCAS.