Description
Steps:
1. First conflict with remote win(doc-#6) and second local conflict(doc-#7). Remote win achieved by delete remote, local change.
2. Resolve the second conflict, resulting in db-sequence(`_lastSequence`) going up, say #8
3. Issue happen, when coming back to resolve remote win case. In case of remote win, winning revision sequence == latest document sequence. We try to add the same revision with same sequence as documentChanged (as per here), trying to add an already past sequence will fail, since document-sequence number #7 is less than db-sequence (#8) (sequence > _lastSequence)
Before this change, all conflict sequence were added to tracker, which will work fine, and later when its resolved the conflict resulted in a new revision sequence(say, #9). And that will be added to tracker, which is a new revision and needs to be replicated to other side.
LiteCore Unit test
https://gist.github.com/jayahariv/9311e9c218549e5e045c120cad09383f
15:29:58.360764| ERROR: Assertion failed: docID && revID && sequence > _lastSequence (/Users/jayaharivavachan/Documents/cbl/couchbase-lite-ios-ee/couchbase-lite-ios/vendor/couchbase-lite-core/LiteCore/Database/SequenceTracker.cc:113, in documentChanged)
|
0 LiteCoreCppTests litecore::SequenceTracker::documentChanged(fleece::alloc_slice const&, fleece::alloc_slice const&, unsigned long long, unsigned long long) + 1457
|
1 LiteCoreCppTests c4Internal::Database::documentSaved(c4Internal::Document*)::$_4::operator()(litecore::SequenceTracker&) const + 2087
|
2 LiteCoreCppTests void litecore::access_lock<litecore::SequenceTracker, std::__1::recursive_mutex>::use<c4Internal::Database::documentSaved(c4Internal::Document*)::$_4>(c4Internal::Database::documentSaved(c4Internal::Document*)::$_4) + 513
|
3 LiteCoreCppTests c4Internal::Database::documentSaved(c4Internal::Document*) + 1277
|
4 LiteCoreCppTests c4Internal::TreeDocument::resolveConflict(FLSlice, FLSlice, FLSlice, unsigned char, bool) + 9780
|
5 LiteCoreCppTests c4doc_resolveConflict::$_11::operator()() const + 1144
|
6 LiteCoreCppTests bool fleece::function_ref<bool ()>::callback_fn<c4doc_resolveConflict::$_11>(long) + 85
|
7 LiteCoreCppTests fleece::function_ref<bool ()>::operator()() const + 191
|
8 LiteCoreCppTests bool c4Internal::tryCatch<bool>(C4Error*, fleece::function_ref<bool ()>) + 367
|
9 LiteCoreCppTests c4doc_resolveConflict + 1366
|
10 LiteCoreCppTests (anonymous namespace)::____C_A_T_C_H____T_E_S_T____921::test() + 53666
|
11 LiteCoreCppTests Catch::MethodTestCase<(anonymous namespace)::____C_A_T_C_H____T_E_S_T____921>::invoke() const + 622
|
12 LiteCoreCppTests Catch::TestCase::invoke() const + 331
|
13 LiteCoreCppTests Catch::RunContext::invokeActiveTestCase() + 434
|
14 LiteCoreCppTests Catch::RunContext::runCurrentTest(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >&) + 4107
|
15 LiteCoreCppTests Catch::RunContext::runTest(Catch::TestCase const&) + 1806
|
16 LiteCoreCppTests Catch::runTests(Catch::Ptr<Catch::Config> const&) + 3881
|
17 LiteCoreCppTests Catch::Session::run() + 1850
|
18 LiteCoreCppTests Catch::Session::run(int, char const* const*) + 126
|
19 LiteCoreCppTests main + 348
|
20 libdyld.dylib start + 1
|
Program ended with exit code: 9
|