Document Revision Issue in android with couchbase Sync gateway

First of all, my testing environment:

Sync Gateway 1.4.1
Couchbase Server 4.6.2
Couchbase-Lite Android 1.4.1

Scenario:
Android is creating a document and updating it within 2-3 second which results to 2nd revision and after 4-6 second android get 1st revision in changes field (when debugged i found the source is sync gateway). On server, we stopped listening the changes

Example:
13:18:21.074 _rev=1-5a2e4bb3a3ec7d6f2753eace744f62f2, _id=C-becf8f48-eae2-4337-a70f-d4d1c16f7eb8, eptime=1521445701050 - in changes source is null
13:18:22.564 _rev=2-48d3f1791920eabadc66a1cd1dab5bbb, _id=C-becf8f48-eae2-4337-a70f-d4d1c16f7eb8, eptime=1521445702560 - in changes source is null
13:18:26.914 _rev=1-bddbe7c4537f956d53b04c8bf5731125, _id=C-becf8f48-eae2-4337-a70f-d4d1c16f7eb8, eptime=1521445701050 - in changes source is sync gateway

but strange thing is that _rev=1-5a2e4b… and _rev=1-bddbe7c… have the exact same data even the eptime

final doc->
{
“_sync”: {
“rev”: “2-48d3f1791920eabadc66a1cd1dab5bbb”,
“new_rev”: “1-bddbe7c4537f956d53b04c8bf5731125”,
“flags”: 28,
“sequence”: 2254886,
“recent_sequences”: [
2254880,
2254883,
2254886
],
“history”: {
“revs”: [
“1-5a2e4bb3a3ec7d6f2753eace744f62f2”,
“2-48d3f1791920eabadc66a1cd1dab5bbb”,
“1-bddbe7c4537f956d53b04c8bf5731125”
],
“parents”: [
-1,
0,
-1
],
“bodymap”: {
“2”: “{“eptime”:“1521445701050”}”
},

}
when creating and updating document in offline mode on android no such condition occurs.

@tanyasrv01,

Looks like you have a conflict.

Here is a link to manage conflicts in Couchbase Lite.
https://developer.couchbase.com/documentation/mobile/1.5/guides/couchbase-lite/native-api/query/index.html#story-h2-2

Here is a video on conflict management on Sync Gateway.

Here is a detailed blog article about Conflicts in Couchbase Mobile.

Ya! I did go through these articles and blog but in my case there is conflict on 1st revision itself and one of the 1st revision is made by android (found in changes.getSource()) and second 1st revision has source sync gateway with exact same data (came after 3-6 sec of 2nd revision). Couchbase server is not handling changes, so connection is with android and syncgateway only. This situation occurs 50:50 ratio.

Ya! I did go through these articles and blog but in my case there is conflict on 1st revision itself and one of the 1st revision is made by android (found in changes.getSource()) and second 1st revision has source sync gateway with exact same data (came after 3-6 sec of 2nd revision). Couchbase server is not handling changes, so connection is with android and syncgateway only. This situation occurs 50:50 ratio.

@tanyasrv01,

When you insert data CBL/SG does not also de-dup for you.
So if you insert the same document twice it will be version two.