Failed to insert 'doc-1' #XXX: LiteCore BadRevisionID, "Invalid version string XXX@XXX, XXX@XXX,XXX@XXX"

I’m testing out Couchbase Mobile + Sync Gateway

Platform: Android 4.0.2 (Kotlin)
Sync Gateway: 4.0.2 enterprise
Couchbase Server: 8.0.0 enterprise
Reproduction: GitHub - ludydoo/tmp-couchbase-mobile-sync-repro (with screen recordings)

I am testing a custom “conflictResolver”, which is able to merge 2 conflicting documents.

The scenario:
Three devices (“dev1”, “dev2”, “dev3”) are connected to Sync Gateway and operating on the same document (“order1”).

Scenario

  1. All devices are online. dev1 adds an item to the order — the document syncs correctly to all devices.

  2. dev2 and dev3 go offline.

  3. dev2 and dev3 independently modify order1

  4. dev2 comes back online; its changes sync correctly to dev1 and dev2.

  5. dev3 comes back online. It receives some changes, but its local state diverges from dev1/dev2. dev2’s replicator’ documentReplicationListener sees an event with error “Invalid version string ‘188ed2b0d61b0000@A6KKjWppSKeo4akbAL5J7w, 188ed2abfb620000@A6KKjWppSKeo4akbAL5J7w,188ed2abc7e20000@m4XlarW6S4Ceb6kua70JwA;’”.

Observed outcomes

  • If dev3 then performs the next mutation, the document eventually converges across all devices. But there is an inconsistent state before the mutation.

  • If dev1 or dev2 performs a mutation after dev3 comes online, the document never converges again — all devices remain in divergent states.

Desired outcome:

  • Documents should converge across all devices when online

Am I doing something wrong?

No, this looks like a bug in the new version-vector feature of CBL 4.0. We’ll investigate; thanks for providing detailed information.

I’m not sure what the cause is, but as a temporary workaround you can back up to the latest 3.x release of Couchbase Lite. It’s still compatible with Sync Gateway 4.0 but it uses the older rev-tree versioning instead of version vectors. Just make sure to remove any existing databases from your device since 3.x cannot read databases created by 4.x. However, when you move back to 4.x the databases will upgrade properly.

Filed a bug report in Jira

Thank you for the reply @jens :folded_hands: