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-4300 improve rosmar XDCR handling #7162

Open
wants to merge 1 commit into
base: release/anemone
Choose a base branch
from
Open

Conversation

torcolvin
Copy link
Collaborator

  • 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)
Copy link
Collaborator

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
}

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 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 {
Copy link
Collaborator

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,
Copy link
Collaborator

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
Copy link
Collaborator

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.

@adamcfraser adamcfraser assigned torcolvin and unassigned adamcfraser Oct 18, 2024
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.

2 participants