I am debugging why we have so many conflicts reported on our customer databases, and while digging through a database I found a few documents that have no conflicts but are being reported as in conflict by the all docs query to retrieve conflicts only. We are using CouchbaseLite 1.4 on iOS. Here is our conflict detection code:
CBLQuery *query = [database createAllDocumentsQuery];
[query setAllDocsMode:kCBLOnlyConflicts];
[query runAsync:^(CBLQueryEnumerator *result, NSError *error) {
// Merge document conflicts, if applicable.
BOOL isMergedConflictSuccessfully = false;
if (IS_NOT_NULL(result)) {
for (CBLQueryRow *row in result) {
if (IS_NOT_NULL(row) &&
IS_NOT_NULL([row conflictingRevisions])) {
isMergedConflictSuccessfully |= [appDelegate mergeRevisions:[row conflictingRevisions] intoDatabase:database];
}
}
}
}
Here is the _sync object for an example document that is reporting a conflict. It is one that the app never saves, it is only touched on the database, and the server reports no conflicting revisions on it:
"_sync": {
“rev”: “10-ac08f67084a93b63a720e3f1500304fa”,
“sequence”: 13685316,
“recent_sequences”: [
13462675,
13540770,
13560263,
13560289,
13560546,
13560596,
13560608,
13560609,
13651267,
13685316
],
“history”: {
“revs”: [
“8-e13f66f27c77afb10160be83ffd7e9d5”,
“4-de7c8257087e0106e387efd99a5e4155”,
“7-8bb422162a2e94536f5ef88129060448”,
“6-2e62c7cb537117e11b0143dcd824defc”,
“3-651eb0b7b2bf70972f10714744372bf1”,
“5-44918514d745114627dfa6c5dfbd88a4”,
“1-3bffda9866ff7a99cace376006693e8a”,
“9-5e5c1ff5e2006ef2a7055e3f93e7ba7e”,
“10-ac08f67084a93b63a720e3f1500304fa”,
“2-f865f8d12e4ba966975d29a55152ab04”
],
“parents”: [
2,
4,
3,
5,
9,
1,
-1,
0,
7,
6
],
“channels”: [
[
“all”
],
[
“all”
],
[
“all”
],
[
“all”
],
[
“all”
],
[
“all”
],
[
“all”
],
[
“all”
],
[
“all”
],
[
“all”
]
]
},
“channels”: {
“all”: null
},
“time_saved”: “2017-05-16T21:12:20.20727175Z”
},
… doc body …
}
Here are the revisions which the app is saying are in conflict, but you can see from the server version they are just normal revisions:
(
“CBLSavedRevision[tran…n_es/10-ac08f67084a93b63a720e3f1500304fa]”,
“CBLSavedRevision[tran…n_es/1-3bffda9866ff7a99cace376006693e8a]”
)
Why is couchbase returning this document, and other similar non-conflicting ones, from the conflicts only query if there is actually no conflict? How do we get only documents that have conflicts from the DB?