Skip to content

CBL-8390: Implement Parse and Compare Non-numeric checkpoint resolution#2496

Closed
jianminzhao wants to merge 2 commits into
release/3.4from
cbl-8390
Closed

CBL-8390: Implement Parse and Compare Non-numeric checkpoint resolution#2496
jianminzhao wants to merge 2 commits into
release/3.4from
cbl-8390

Conversation

@jianminzhao

Copy link
Copy Markdown
Contributor

No description provided.

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

This is a release branch and commits are restricted.

Please confirm this PR is one of the following:

  • A response to a customer ask
  • A change per our security policy
  • A non-functional change (i.e. changes needed for building an older version)
  • A change that has been granted an exception (please comment)

@jianminzhao

Copy link
Copy Markdown
Contributor Author

Auto merged from master branch

@cbl-bot

cbl-bot commented Jun 5, 2026

Copy link
Copy Markdown

Code Coverage Results:

Type Percentage
branches 64.53
functions 77.35
instantiations 70.94
lines 75.91
regions 72.16

@jianminzhao

Copy link
Copy Markdown
Contributor Author

The ticket is assigned to release/3.4
Update of tools submodule is non-functional. It is to match the corresponding release branch.

Copilot AI left a comment

Copy link
Copy Markdown

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 introduces support for parsing and ordering Sync Gateway compound (non-numeric) remote sequence IDs so checkpoint mismatch resolution can roll back/ignore correctly instead of resetting replication when sequences aren’t plain integers.

Changes:

  • Add ParsedSequenceID type with parse() and before() ordering rules aligned with Sync Gateway’s checkpoint comparison semantics.
  • Teach checkpoint validation to compare parsed remote sequences (including compound formats) and only roll back when the server checkpoint is actually earlier.
  • Add a comprehensive unit test suite for parsing/classification/comparison rules, and wire it into the CMake test target.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
Replicator/tests/ParsedSequenceIDTest.cc New unit tests covering parsing/classification and cross-format ordering semantics.
Replicator/RemoteSequence.hh Adds conversion helper to parse remote sequence values into ParsedSequenceID.
Replicator/ParsedSequenceID.hh New header implementing parsing + ordering rules for compound sequence IDs.
Replicator/Checkpoint.cc Updates checkpoint mismatch logic to compare parsed sequences instead of only numeric sequences.
LiteCore/tests/CMakeLists.txt Adds the new test file to the LiteCore test executable.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +78 to +86
/** Convert this RemoteSequence to a ParsedSequenceID. Returns false if unparseable. */
[[nodiscard]] bool toParsedSequenceID(ParsedSequenceID& out) const {
if ( !*this ) return false;
if ( isInt() ) {
out = {intValue(), 0, 0};
return true;
}
return ParsedSequenceID::parse(std::string(sliceValue()), out);
}
Comment on lines +1 to +3
#include "ParsedSequenceID.hh"
#include "c4Test.hh"

Comment thread Replicator/Checkpoint.cc
Comment on lines +118 to 137
ParsedSequenceID localParsed, remoteParsed;
bool localParseable = _remote.toParsedSequenceID(localParsed);
bool remoteParseable = remoteSequences._remote.toParsedSequenceID(remoteParsed);
if ( localParseable && remoteParseable ) {
if ( remoteParsed.before(localParsed) ) {
LogTo(SyncLog, "Rolling back to earlier remote sequence from server, some redundant changes may be "
"proposed...");
_remote = remoteSequences._remote;
match = false;
} else {
LogTo(SyncLog, "Ignoring remote sequence on server since client side is older, some redundant "
"changes may be proposed...");
LogTo(SyncLog, "Ignoring remote sequence on server since client side is older or equal, some "
"redundant changes may be proposed...");
}
} else {
Warn("Non-numeric remote sequence detected, resetting replication back to start. Redundant changes "
"will be proposed...");
Warn("Unparseable remote sequence: locally-saved remote seq '%s' is %s, "
"server-side remote seq '%s' is %s. Resetting replication.",
_remote.toJSONString().c_str(), localParseable ? "parseable" : "UNPARSEABLE",
remoteSequences._remote.toJSONString().c_str(), remoteParseable ? "parseable" : "UNPARSEABLE");
_remote = {};
match = false;
Comment on lines +1 to +6
#pragma once
#include "StringUtil.hh"
#include "slice_stream.hh"
#include <cstdint>
#include <string>

@couchbase couchbase deleted a comment from github-actions Bot Jun 5, 2026
@jianminzhao jianminzhao closed this Jun 5, 2026
@jianminzhao jianminzhao deleted the cbl-8390 branch June 5, 2026 22:58
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.

4 participants