Skip to content

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

Merged
merged 3 commits into from
Aug 8, 2025
Merged

CBG-4780: basic ISGR push and pull for 4.0 #7668

merged 3 commits into from
Aug 8, 2025

Conversation

gregns1
Copy link
Contributor

@gregns1 gregns1 commented Aug 7, 2025

CBG-4780

  • PR does the minimum to get ISGR running in 4.0 replication. Conflicts are not handled yet.
  • Some test are skipped due to conflict issues (not implemented)
  • Some test assertions are changed given we don't currently keep rev IDs in sync each side of the replication (diff revIDs being generated each side even on new doc writes) so CV is only asserted at this time. I have linked tickets to change these when work takes place in other tickets.
  • I have also linked work in the write REST API work to change assertions based on that work too
  • One particular test is forced to run in 3.0 mode due to asserting docs created with same revIDs and bodies each each side get marked as peer doesn't want and asserts some check pointing behaviour around this. This is not applicable to 4.0 replication. Given we don’t generate same versions for docs with same id's and bodies like we do with revIDs.
  • New function to check incoming changes on changes message. I have tried to keep same sort of structure as RevsDiff given I think we can use known revs property for the rev tree property added later.
  • I will enhance conflict detecting for push replications on changes message in ticket CBG-4792 (similar behaviour to what proposeChanges does)
  • I have moved assertion changes from CBG-4288: some assertion cleanups for active replicator tests #7665 to here and will close it

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

Dependencies (if applicable)

  • Link upstream PRs
  • Update Go module dependencies when merged

Integration Tests

@gregns1 gregns1 self-assigned this Aug 7, 2025
@Copilot Copilot AI review requested due to automatic review settings August 7, 2025 09:40
Copy link
Contributor

@Copilot Copilot AI left a comment

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 implements basic Inter-Sync Gateway Replication (ISGR) push and pull functionality for version 4.0 protocol. It focuses on getting ISGR operational with minimal conflict handling support.

Key changes include:

  • Addition of new version checking functions for ISGR changes message handling
  • Updated test assertions to accommodate different revision ID generation between active and passive nodes
  • Temporary skipping of conflict resolution tests until proper ISGR conflict handling is implemented

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
rest/utilities_testing.go Adds new test utility functions for version comparison and changes assertion logic for ISGR
rest/replicatortest/replicator_test_helper.go Removes unused test helper function
rest/replicatortest/replicator_test.go Updates test assertions and skips conflict-related tests for ISGR compatibility
rest/blip_api_crud_test.go Skips test due to revision tree differences between active and passive nodes
rest/attachment_test.go Removes test function related to attachment handling
db/utilities_hlv_testing.go Adds new function for revision tree equality checking
db/document.go Adds method to extract document version from Document struct
db/crud.go Implements CheckChangeVersion function for ISGR change handling
db/blip_handler.go Updates changes message handling to support version vectors and removes conflict resolver restriction
db/active_replicator_common.go Removes hardcoded BLIP protocol version restriction

}

// RequireDocVersionNotEqual calls t.Fail if two document versions are equal.
func RequireDocVersionNotEqual(t *testing.T, expected, actual DocVersion) {
require.False(t, expected.Equal(actual), "Versions match. Version should not be %s", expected)
// CBG-4751: should be able to uncomment this line once cv is included in write response
//require.NotEqual(t, expected.CV.String(), actual.CV.String(), "Versions mismatch. Expected: %v, Actual: %v", expected, actual)
Copy link
Preview

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

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

This commented-out code contains dev-time logging that should be removed rather than commented out. Either remove the line entirely or replace with appropriate Sync Gateway logging if needed.

Copilot uses AI. Check for mistakes.

@@ -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)
Copy link
Preview

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The 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.

@@ -5921,6 +5959,8 @@ func TestActiveReplicatorPullConflictReadWriteIntlProps(t *testing.T) {
func TestSGR2TombstoneConflictHandling(t *testing.T) {
base.LongRunningTest(t)
base.RequireNumTestBuckets(t, 2)
base.SetUpTestLogging(t, base.LevelDebug, base.KeyAll)
Copy link
Preview

Copilot AI Aug 7, 2025

Choose a reason for hiding this comment

The 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.

@@ -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)
Copy link
Preview

Copilot AI Aug 7, 2025

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.

@@ -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)
Copy link
Preview

Copilot AI Aug 7, 2025

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.

// - Put a doc on a active rest tester
// - Create replication and wait for the doc to be replicated to passive node
// - Assert on the HLV in the metadata of the replicated document
func TestReplicatorUpdateHLVOnPut(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

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

Try a REST API PUT with new_edits=false to ensure we're generating a CV for a rev-ID write.

@bbrks bbrks merged commit 972d34b into main Aug 8, 2025
44 checks passed
@bbrks bbrks deleted the CBG-4780 branch August 8, 2025 11:23
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