From d35a44385756777513c79ed18185c2a242b23776 Mon Sep 17 00:00:00 2001 From: Tor Colvin Date: Thu, 31 Jul 2025 09:32:58 -0400 Subject: [PATCH 1/2] Fix comments and codes about handling proposeChanges --- db/crud.go | 2 +- rest/utilities_testing_blip_client.go | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/db/crud.go b/db/crud.go index e974e6fe81..8499bb3409 100644 --- a/db/crud.go +++ b/db/crud.go @@ -3318,7 +3318,7 @@ func (db *DatabaseCollectionWithUser) CheckProposedVersion(ctx context.Context, // previousVersion didn't match, but proposed version and server CV have matching source, and proposed version is newer return ProposedRev_OK, "" } else { - // Temporary (CBG-4466): check the full HLV that's being sent by CBL with proposeChanges messages. + // Temporary (CBG-4461): check the full HLV that's being sent by CBL with proposeChanges messages. // If the current server cv is dominated by the incoming HLV (i.e. the incoming HLV has an entry for the same source // with a version that's greater than or equal to the server's cv), then we can accept the proposed version. proposedHLV, _, err := ExtractHLVFromBlipMessage(proposedHLVString) diff --git a/rest/utilities_testing_blip_client.go b/rest/utilities_testing_blip_client.go index 245a61e44f..8f79d5deb8 100644 --- a/rest/utilities_testing_blip_client.go +++ b/rest/utilities_testing_blip_client.go @@ -1204,14 +1204,20 @@ func (btcc *BlipTesterCollectionClient) sendProposeChanges(ctx context.Context, if i > 0 { proposeChangesRequestBody.WriteString(",") } - proposeChangesRequestBody.WriteString(fmt.Sprintf(`["%s","%s"`, change.docID, change.Rev())) + rev := change.Rev() + if btcc.UseHLV() { + // Until CBG-4461 is implemented the second value in the array is the full HLV. + rev += "," + change.historyStr() + } + fmt.Fprintf(proposeChangesRequestBody, `["%s","%s"`, change.docID, rev) + // write last known server version to support no-conflict mode if serverVersion, ok := btcc.getLastReplicatedRev(change.docID); ok { base.DebugfCtx(ctx, base.KeySGTest, "specifying last known server version for doc %s = %v", change.docID, serverVersion) if btcc.UseHLV() { - proposeChangesRequestBody.WriteString(fmt.Sprintf(`,"%s"`, serverVersion.CV.String())) + fmt.Fprintf(proposeChangesRequestBody, `,"%s"`, serverVersion.CV.String()) } else { - proposeChangesRequestBody.WriteString(fmt.Sprintf(`,"%s"`, serverVersion.RevTreeID)) + fmt.Fprintf(proposeChangesRequestBody, `,"%s"`, serverVersion.RevTreeID) } } proposeChangesRequestBody.WriteString(`]`) @@ -1274,6 +1280,11 @@ func (btcc *BlipTesterCollectionClient) sendRev(ctx context.Context, change prop btcc.sendRev(ctx, change, false) return } + if errorCode == strconv.Itoa(http.StatusConflict) { + // If there is a conflict created between the proceeding proposeChanges and this rev message. + // this is not an error. + return + } require.NotContains(btcc.TB(), revResp.Properties, "Error-Domain", "unexpected error response from rev %#v", revResp) base.DebugfCtx(ctx, base.KeySGTest, "peer acked rev %s / %v", change.docID, change.version) btcc.updateLastReplicatedRev(change.docID, change.version, revRequest) From 1a82a558bda7602151c7ead2592cc8d47c13204f Mon Sep 17 00:00:00 2001 From: Tor Colvin Date: Thu, 31 Jul 2025 09:39:17 -0400 Subject: [PATCH 2/2] Update rest/utilities_testing_blip_client.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- rest/utilities_testing_blip_client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rest/utilities_testing_blip_client.go b/rest/utilities_testing_blip_client.go index 8f79d5deb8..b13f6fdb5d 100644 --- a/rest/utilities_testing_blip_client.go +++ b/rest/utilities_testing_blip_client.go @@ -1281,7 +1281,7 @@ func (btcc *BlipTesterCollectionClient) sendRev(ctx context.Context, change prop return } if errorCode == strconv.Itoa(http.StatusConflict) { - // If there is a conflict created between the proceeding proposeChanges and this rev message. + // If there is a conflict created between the preceding proposeChanges and this rev message. // this is not an error. return }