Skip to content

CBG-5106: Incorrect history being sent for legacy revision cases in delta sync#8307

Merged
torcolvin merged 6 commits into
mainfrom
CBG-5106
Jun 3, 2026
Merged

CBG-5106: Incorrect history being sent for legacy revision cases in delta sync#8307
torcolvin merged 6 commits into
mainfrom
CBG-5106

Conversation

@gregns1

@gregns1 gregns1 commented May 28, 2026

Copy link
Copy Markdown
Contributor

CBG-5106

  • Move rev message history builder into a shared function to be called from multiple places in the code
  • Fixes scenario where empty history is sent for a SGW rev that has CV but a client rev that is legacy rev.
  • Introduces some lower level tests to assert on this behaviour.

QE tests now show history being sent correctly for both test cases in the linked ticket:

2026-05-28T10:50:40.398+01:00 [DBG] Sync+: c:[65248013] db:upgrade col:_default Sending rev "<ud>nonconflict_3</ud>" 18b3b1dcf40d0000@Qmce34epjCesjaS8myHE+Q as delta. DeltaSrc:2-509dc0903869f6b103fd1266b169e73876b80d27
2026-05-28T10:50:40.398+01:00 [TRC] SyncMsg+: c:[65248013] db:upgrade Sent Req MSG#3~: Body: '<ud>{"updated_by":"delta_sync_history_test"}</ud>' Properties: <ud>map[Content-Type:application/json Profile:rev collection:0 deltaSrc:2-509dc0903869f6b103fd1266b169e73876b80d27 history:3-3a1c6412b5433949e8ed130d996300a7,2-509dc0903869f6b103fd1266b169e73876b80d27 id:nonconflict_3 rev:18b3b1dcf40d0000@Qmce34epjCesjaS8myHE+Q sequence:34]</ud>
...
2026-05-28T10:51:31.840+01:00 [DBG] Sync+: c:[78356265] db:upgrade col:_default Sending rev "<ud>nonconflict_2</ud>" 2-36a2cfe8544956ad3c5b6491cbfc7d94 as delta. DeltaSrc:1-e643a00fb9cad8cf87ee4d2c4e2383f6ecf118c0
2026-05-28T10:51:31.840+01:00 [TRC] SyncMsg+: c:[78356265] db:upgrade Sent Req MSG#3~: Body: '<ud>{"number":2}</ud>' Properties: <ud>map[Content-Type:application/json Profile:rev collection:0 deltaSrc:1-e643a00fb9cad8cf87ee4d2c4e2383f6ecf118c0 history:1-e643a00fb9cad8cf87ee4d2c4e2383f6ecf118c0 id:nonconflict_2 rev:2-36a2cfe8544956ad3c5b6491cbfc7d94 sequence:6]

Pre-review checklist

  • Removed debug logging (fmt.Print, log.Print, ...)
  • Logging sensitive data? Make sure it's tagged (e.g. base.UD(docID), base.MD(dbName))
  • Updated relevant information in the API specifications (such as endpoint descriptions, schemas, ...) in docs/api

Integration Tests

Copilot AI review requested due to automatic review settings May 28, 2026 10:55

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes CBG-5106, where delta-sync rev messages sent to a legacy (pre-HLV) client could end up with an empty/incorrect history property, breaking conflict detection on the receiver. The fix centralizes the previously duplicated history-construction logic across sendRevision, sendDelta, and sendRevAsDelta (redacted path), and propagates the remoteIsLegacyRev flag through sendRevAsDelta into sendDelta so the delta path can produce the same history as the full-revision path.

Changes:

  • Introduce buildRevHistory/revHistoryInput to centralize rev-message history construction for the 5 local/remote legacy-vs-HLV scenarios, with extensive scenario documentation.
  • Plumb remoteIsLegacyRev through sendRevAsDeltasendDelta (and fallback sendRevision calls) so deltas to legacy clients include [hlvHistory, revID, revTreeHistory...].
  • Add two new lower-level BLIP tests for the delta + legacy-client case and unskip the previously skipped TestActiveReplicatorDeltaSyncWhenBothSidesLegacy.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
db/blip_sync_context.go Adds buildRevHistory helper with scenario docs; sendDelta now takes remoteIsLegacyRev and uses the helper; sendRevision refactored to use the helper.
db/blip_handler.go sendRevAsDelta takes remoteIsLegacyRev, propagates it to fallback sendRevision and sendDelta calls, and uses buildRevHistory for the redacted-rev path.
rest/blip_legacy_revid_test.go Adds two tests verifying delta history sent to legacy clients (with and without HLV pv history).
rest/replicatortest/replicator_test_legacy_rev_test.go Removes t.Skip from TestActiveReplicatorDeltaSyncWhenBothSidesLegacy now that the fix lands.

Comment thread rest/blip_legacy_revid_test.go Outdated

@torcolvin torcolvin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this code looks good but I would feel much better about the tests if they didn't override the handlers and used the standard BlipTestClientRunner. Is there a reason taht they aren't using this?

Comment thread rest/blip_legacy_revid_test.go Outdated
Comment thread rest/blip_legacy_revid_test.go Outdated
@torcolvin

Copy link
Copy Markdown
Collaborator

Do we need an extra tests for ISGR?

@torcolvin torcolvin assigned gregns1 and unassigned torcolvin Jun 1, 2026

@gregns1 gregns1 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No extra test needed for ISGR, ISGR already has delta sync tests but the original bug wasn't found as rev trees are always sent in ISGR case in the rev tree property.

@gregns1 gregns1 assigned torcolvin and unassigned gregns1 Jun 2, 2026
@torcolvin torcolvin assigned gregns1 and unassigned torcolvin Jun 3, 2026
@torcolvin torcolvin merged commit 2b9ed17 into main Jun 3, 2026
69 of 70 checks passed
@torcolvin torcolvin deleted the CBG-5106 branch June 3, 2026 14:05
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.

3 participants