-
Notifications
You must be signed in to change notification settings - Fork 140
CBG-4780: basic ISGR push and pull for 4.0 #7668
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -695,10 +695,23 @@ func (bh *blipHandler) handleChanges(rq *blip.Message) error { | |
expectedSeqs := make(map[IDAndRev]SequenceID, 0) | ||
alreadyKnownSeqs := make([]SequenceID, 0) | ||
|
||
versionVectorProtocol := bh.useHLV() | ||
|
||
for _, change := range changeList { | ||
docID := change[1].(string) | ||
revID := change[2].(string) | ||
missing, possible := bh.collection.RevDiff(bh.loggingCtx, docID, []string{revID}) | ||
rev := change[2].(string) | ||
var missing, possible []string | ||
|
||
changeIsVector := false | ||
if versionVectorProtocol { | ||
changeIsVector = strings.Contains(rev, "@") | ||
} | ||
if !versionVectorProtocol || !changeIsVector { | ||
missing, possible = bh.collection.RevDiff(bh.loggingCtx, docID, []string{rev}) | ||
} else { | ||
missing, possible = bh.collection.CheckChangeVersion(bh.loggingCtx, docID, rev) | ||
} | ||
|
||
if nWritten > 0 { | ||
output.Write([]byte(",")) | ||
} | ||
|
@@ -740,7 +753,7 @@ func (bh *blipHandler) handleChanges(rq *blip.Message) error { | |
if collectionCtx.sgr2PullAlreadyKnownSeqsCallback != nil { | ||
seq, err := ParseJSONSequenceID(seqStr(bh.loggingCtx, change[0])) | ||
if err != nil { | ||
base.WarnfCtx(bh.loggingCtx, "Unable to parse known sequence %q for %q / %q: %v", change[0], base.UD(docID), revID, err) | ||
base.WarnfCtx(bh.loggingCtx, "Unable to parse known sequence %q for %q / %q: %v", change[0], base.UD(docID), rev, err) | ||
} else { | ||
// we're not able to checkpoint a sequence we can't parse and aren't expecting so just skip the callback if we errored | ||
alreadyKnownSeqs = append(alreadyKnownSeqs, seq) | ||
|
@@ -763,9 +776,9 @@ func (bh *blipHandler) handleChanges(rq *blip.Message) error { | |
seq, err := ParseJSONSequenceID(seqStr(bh.loggingCtx, change[0])) | ||
if err != nil { | ||
// We've already asked for the doc/rev for the sequence so assume we're going to receive it... Just log this and carry on | ||
base.WarnfCtx(bh.loggingCtx, "Unable to parse expected sequence %q for %q / %q: %v", change[0], base.UD(docID), revID, err) | ||
base.WarnfCtx(bh.loggingCtx, "Unable to parse expected sequence %q for %q / %q: %v", change[0], base.UD(docID), rev, err) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of base.UD() to wrap the docID for user data redaction in logging. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
} else { | ||
expectedSeqs[IDAndRev{DocID: docID, RevID: revID}] = seq | ||
expectedSeqs[IDAndRev{DocID: docID, RevID: rev}] = seq | ||
} | ||
} | ||
} | ||
|
@@ -1002,10 +1015,6 @@ func (bh *blipHandler) processRev(rq *blip.Message, stats *processRevStats) (err | |
} | ||
} | ||
|
||
if bh.useHLV() && bh.conflictResolver != nil { | ||
return base.HTTPErrorf(http.StatusNotImplemented, "conflict resolver handling (ISGR) not yet implemented for v4 protocol") | ||
} | ||
|
||
// throttle concurrent revs | ||
if cap(bh.inFlightRevsThrottle) > 0 { | ||
select { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2752,6 +2752,8 @@ func TestBlipInternalPropertiesHandling(t *testing.T) { | |
// the stat mapping (processRevStats) | ||
func TestProcessRevIncrementsStat(t *testing.T) { | ||
base.RequireNumTestBuckets(t, 2) | ||
base.SetUpTestLogging(t, base.LevelDebug, base.KeyAll) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Debug logging setup in tests should be removed before production. This appears to be dev-time logging that was left in. Copilot uses AI. Check for mistakes. Positive FeedbackNegative Feedback |
||
t.Skip("CBG-4791 - rev tree generated on active is different from passive, this will be mitigated by CBG-4791") | ||
|
||
activeRT, remoteRT, remoteURLString, teardown := SetupSGRPeers(t) | ||
defer teardown() | ||
|
@@ -2783,6 +2785,7 @@ func TestProcessRevIncrementsStat(t *testing.T) { | |
require.EqualValues(t, 0, pullStats.HandlePutRevCount.Value()) | ||
|
||
const docID = "doc" | ||
// need to have this return CV too, pending CBG-4751 | ||
version := remoteRT.CreateTestDoc(docID) | ||
|
||
assert.NoError(t, ar.Start(activeCtx)) | ||
|
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.
Good use of base.UD() to wrap the docID for user data redaction in logging.
Copilot uses AI. Check for mistakes.