Sync Gateway not push latest document if device is not connected

Hi,
i’m using

  • Android os
  • CBL v 2.0.0-DB020
  • sync gateway v 1.5

I’m facing a weird problem. If i create a new document with sync gateway, if my device is connected everything works fine, but, if my device is offline or the app is kill, the document is not pushed to the device when it returns online. Then, if i update the document creating a new revision, the document is correctly pushed and showed.

My sync gateway function is:

function (doc, oldDoc) {
        channel(doc.channels);
}

and i’m using a continuous replication.

Another thing i notice is that if i add for example 5 documents when the device is offline, and then came back online, sync gateway push only the first four docs. Then, if i add another document(always when the device is offline), when online SC push the 5th document created previously, not pushing the last one(the 6th).

What could it be?

OK. So if you created two documents in offline mode , does only one get synced up when you come back online ?

We have fixed a bunch of replication related issues since DB020. This particular issue does not ring a bell. @hideki - thoughts ?

Yes, the last one is not replicated

This is a weird problem and not one that I am aware of . I would suggest testing with DB021 to see if issue surfaces. DB020 is several months old. That said, DB22 is around the corner and resolves several replication issues - so maybe this is handled as well.

Hi,
i updated the db, now i’m using v DB21.
I create a new application with only a single anctivity and this code in onCreate():

...
DatabaseConfiguration config = new DatabaseConfiguration(getApplicationContext());
        Database database = null;
        try {
            database = new Database(DB_NAME, config);
        } catch (CouchbaseLiteException e) {
            e.printStackTrace();
        }
        database.addChangeListener(new DatabaseChangeListener() {
            @Override
            public void changed(DatabaseChange change) {
                List<String> ids = change.getDocumentIDs();
                for(String id : ids) {
                    Log.d("CHANGEID", id);
                }
            }
        });

        URI uri = null;
        try {
            uri = new URI("blip://192.168.1.27:4984/default_cluster");
        } catch (URISyntaxException e) {
            e.printStackTrace();
        }

        ReplicatorConfiguration replConfig = new ReplicatorConfiguration(database, uri);
        replConfig.setContinuous(true);

        List<String> channels = new ArrayList<>();
        channels.add("test_channel");
        replConfig.setChannels(channels);

        Authenticator auth = new BasicAuthenticator(USERNAME, PASSWORD);
        replConfig.setAuthenticator(auth);
        Replicator replicator = new Replicator(replConfig);
        replicator.addChangeListener(new ReplicatorChangeListener() {
            @Override
            public void changed(ReplicatorChange change) {
                Log.d("REPLICATORSTATUS", change.getReplicator().getStatus().getActivityLevel().toString());
            }
        });
        replicator.start();

If i create a new document or update a document, in DatabaseChangeListener i see the document’s id updated. Instead, if i add/update the document offline and then came back online, theDatabaseChangeListener is never called, although the replicator status becomes “IDLE” after “BUSY” process( so for what i know, the replication should be finished and the new docs should have been added to the DB).
So i thought that the error i previously posted regards the use of the database’s listener like that.
Am i right?
In that case, how can i know whether the database has been update or not(i need to know if a document has been inserted, or updated, or deleted)?
I’d like to avoid LiveQueries, because i need to know if at least a document has changed, maybe a different one which is not related to the query.
Another thing: i have a lot of document’s with test_channel associated, but in my new app they do not pushed until i update them. So i think sync gateway adds only the new document during connection. instead if the document has already been pushed, the sync of the new change is pushed even during offline operation. Is it possible?

OK, as I understand - if you add/ update a document, the DatabaseChangeListener called - as expected. So thats good.

You shouldn’t expect the see the DatabaseChangeListener invoked when you are doing a push replication. there is no change to local DB. Did you check to see if the document is at the SGW/ server ? You can query using the REST API.

You will use the change object to query for list of document IDs. Then for each Id, fetch document with specified Id.
If it returns nil, that indicates that document is deleted. If it is not nil, it means that document was either added or updated. There is currently no way to distinguish between the two- Typically, is you will probably have a local model / array of documents that you are working with. You can then compare that local copy with the one returned by change object to determine new document additions.

Hmm…didnt quite follow the question. Maybe an example will help illustrate this case . But in general, any time a document change occurs (whether new doc is added or existing doc is updated) - whether the device is online or offline, that change will get synced over to the Sync Gateway.

Hi,
thank you for your very detailed answer.
You have to forgive me, but i confuse push with pull. For push i meant “push from sync gateway”, so, to be specific, what is not working is the pull part of the replication.

Indeed, if i add a document when the device is offline(add the document in the sync gateway server), the document is not pulled: to be sure i get all the document in my database i can see that the new doc is not there.

Until i update the document(from sync gateway, creating a new revision using the sync gateway interface), the document won’t be pulled to my device.
When i update it, if the device is online, it is correctly pulled from the server to the device.

Again, i’m really sorry to confuse push with pull.

Ah OK. Yeah- that changes a lot of things…

Before proceeding to troubleshoot this, can you confirm that that the original issue stated below is not an issue in DB021.

So if you created two documents in offline mode , does only one get synced up when you come back online

No, as you suggested, i used DB021, and the problem still there.
I’ve done:

  1. kill the app
  2. create two docs with sync gateway
  3. re-open the app
  4. query all the documents in the db, and only the first one has been returned

This is a pretty standard scenario so its odd that you are observing this.
We would need relevant logs to see what is going on. For the scenario above, can you please collect SGW logs and share it .
Also, if you can share the logical logs from the Android app.

  1. Open the app
    Android Log:

02-07 09:15:39.879 15913-15913/com.crossroad.ambulapp I/LiteCore [DB]: Opening DataFile /data/data/com.crossroad.ambulapp/files/default_cluster.cblite2/db.sqlite3
02-07 09:15:39.891 15913-15913/com.crossroad.ambulapp I/LiteCore [SQL]: DROP INDEX IF EXISTS "TypeIndex"
02-07 09:15:39.891 15913-15913/com.crossroad.ambulapp I/LiteCore [SQL]: DROP TABLE IF EXISTS "kv_default::TypeIndex"
02-07 09:15:39.892 15913-15913/com.crossroad.ambulapp I/LiteCore [SQL]: CREATE INDEX "TypeIndex" ON kv_default (fl_value(body, 'type'))
02-07 09:15:39.910 15913-15913/com.crossroad.ambulapp I/LiteCoreJNI: [NATIVE] C4Replicator.create()
02-07 09:15:39.910 15913-15913/com.crossroad.ambulapp I/LiteCore [DB]: Opening DataFile /data/data/com.crossroad.ambulapp/files/default_cluster.cblite2/db.sqlite3
02-07 09:15:39.912 15913-15913/com.crossroad.ambulapp I/LiteCore [BLIP]: {N8litecore4blip10ConnectionE#1}==> N8litecore4blip10ConnectionE ->blip:192.168.1.16:4984/default_cluster/_blipsync
02-07 09:15:39.912 15913-15913/com.crossroad.ambulapp I/LiteCore [BLIP]: {N8litecore4blip10ConnectionE#1} Opening connection...
02-07 09:15:39.912 15913-15913/com.crossroad.ambulapp I/LiteCore [Actor]: Starting Scheduler<0xe03147c0> with 4 threads
02-07 09:15:39.914 15913-15913/com.crossroad.ambulapp I/LiteCoreJNI: [NATIVE] C4Replicator.create() repl -> 0x0xe0318680
02-07 09:15:39.914 15913-15913/com.crossroad.ambulapp I/LiteCoreJNI: [NATIVE] C4Replicator.getStatus() repl -> 0xe0318680
02-07 09:15:39.915 15913-16229/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.open() socket -> 0xebc74c48, scheme -> blip, hostname -> 192.168.1.16, port -> 4984, path -> /default_cluster/_blipsync
02-07 09:15:39.915 15913-16229/com.crossroad.ambulapp E/C4Socket: optionsFleece: not null
02-07 09:15:39.916 15913-15913/com.crossroad.ambulapp E/Sync: Replicator[<*> blip://192.168.1.16:4984/default_cluster] is connecting, progress 0/0, error: null
02-07 09:15:39.920 15913-16229/com.crossroad.ambulapp E/C4Socket: options = {channels=[transports_company_id, car_2], auth={username=root, type=Basic, password=123456}, headers={User-Agent=CouchbaseLite/2.0.0-231 (Java; Android 5.0; ASUS_Z00AD) Build/0 Commit/08db03d}, WS-Protocols=BLIP}
02-07 09:15:40.009 15913-15913/com.crossroad.ambulapp W/System.err: WARNING: could not load Java7 Path class
02-07 09:15:40.115 15913-16233/com.crossroad.ambulapp E/WebSocket: WebSocketListener.onOpen() response -> Response{protocol=http/1.1, code=101, message=Switching Protocols, url=http://192.168.1.16:4984/default_cluster/_blipsync}
02-07 09:15:40.116 15913-16233/com.crossroad.ambulapp E/WebSocket: receivedHTTPResponse() httpStatus -> 101
02-07 09:15:40.116 15913-16233/com.crossroad.ambulapp I/LiteCore [BLIP]: {N8litecore4blip10ConnectionE#1} Connected!
02-07 09:15:40.117 15913-16230/com.crossroad.ambulapp I/LiteCore [Sync]: {Repl#1}==> N8litecore4repl10ReplicatorE ->blip:192.168.1.16:4984/default_cluster/_blipsync
02-07 09:15:40.117 15913-16230/com.crossroad.ambulapp I/LiteCore [Sync]: {Repl#1} BLIP Connected
02-07 09:15:40.117 15913-16230/com.crossroad.ambulapp I/LiteCore [Sync]: {Repl#1} now busy
02-07 09:15:40.117 15913-16230/com.crossroad.ambulapp I/LiteCoreJNI: [NATIVE] C4Replicator.statusChangedCallback() repl -> 0x0xe0318680 status -> 4
02-07 09:15:40.118 15913-16230/com.crossroad.ambulapp E/C4Replicator: statusChangedCallback() handle -> 3761342080, status -> C4ReplicatorStatus{activityLevel=4, progressUnitsCompleted=0, progressUnitsTotal=0, progressDocumentCount=0, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:15:40.120 15913-16230/com.crossroad.ambulapp I/LiteCore [Sync]: {DBWorker#2}==> N8litecore4repl8DBWorkerE ->blip:192.168.1.16:4984/default_cluster/_blipsync
02-07 09:15:40.120 15913-16230/com.crossroad.ambulapp I/LiteCore [Sync]: {DBWorker#2} now idle
02-07 09:15:40.121 15913-16232/com.crossroad.ambulapp I/LiteCore [Sync]: {Repl#1} Local checkpoint 'cp-N9riGjO8/fswtgMruH1N/aUdvUg=' is [230, '']; getting remote ...
02-07 09:15:40.123 15913-16229/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.write() handle -> 0xebc74c48, allocatedData.length -> 58
02-07 09:15:40.467 15913-16233/com.crossroad.ambulapp E/WebSocket: WebSocketListener.onMessage() bytes -> 01010c72657600302d3300040005007b226c6f63616c223a3233307d
02-07 09:15:40.467 15913-16231/com.crossroad.ambulapp I/LiteCore [Sync]: {Repl#1} Received remote checkpoint: '{"local":230}'
02-07 09:15:40.467 15913-16231/com.crossroad.ambulapp I/LiteCore [Sync]: {Repl#1} ...got remote checkpoint: [230, ''] rev='0-3'
02-07 09:15:40.467 15913-16231/com.crossroad.ambulapp I/LiteCore [Sync]: {Push#3}==> N8litecore4repl6PusherE ->blip:192.168.1.16:4984/default_cluster/_blipsync
02-07 09:15:40.468 15913-16231/com.crossroad.ambulapp I/LiteCore [Sync]: {Push#3} Starting continuous push from local seq 1
02-07 09:15:40.468 15913-16231/com.crossroad.ambulapp I/LiteCore [Sync]: {Push#3} Reading 200 changes since sequence 230 ...
02-07 09:15:40.468 15913-16230/com.crossroad.ambulapp I/LiteCore [Sync]: {Pull#4}==> N8litecore4repl6PullerE ->blip:192.168.1.16:4984/default_cluster/_blipsync
02-07 09:15:40.468 15913-16230/com.crossroad.ambulapp I/LiteCore [Sync]: {Pull#4} Starting pull from remote seq 
02-07 09:15:40.468 15913-16232/com.crossroad.ambulapp I/LiteCore [Sync]: {DBWorker#2} Reading up to 200 local changes since #230
02-07 09:15:40.468 15913-16230/com.crossroad.ambulapp I/LiteCore [Sync]: {Pull#4} now busy
02-07 09:15:40.468 15913-16231/com.crossroad.ambulapp I/LiteCore [Sync]: {Push#3} now busy
02-07 09:15:40.468 15913-16232/com.crossroad.ambulapp I/LiteCore [Sync]: {Push#3} Caught up, at lastSequence 230
02-07 09:15:40.468 15913-16232/com.crossroad.ambulapp I/LiteCore [Sync]: {Push#3} now idle
02-07 09:15:40.469 15913-16230/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.write() handle -> 0xebc74c48, allocatedData.length -> 109
02-07 09:15:40.469 15913-16233/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.completedReceive() socket -> 0xebc74c48, byteCount -> 28
02-07 09:15:40.470 15913-16230/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.write() handle -> 0xebc74c48, allocatedData.length -> 15
{"WHAT":[["._id"],["."]],"ORDER_BY":[[".when.time"]],"WHERE":["AND",["AND",["=",[".type"],"Transport"],["=",[".car_id"],"car_2"]],["=",[".when.date"],"2018-02-08"]]}
02-07 09:15:40.726 15913-15913/com.crossroad.ambulapp I/LiteCore [SQL]: Compiled Query: SELECT key, fl_root(body) FROM kv_default WHERE ((fl_value(body, 'type') = 'Transport' AND fl_value(body, 'car_id') = 'car_2') AND fl_value(body, 'when.date') = '2018-02-08') AND (flags & 1) = 0 ORDER BY fl_value(body, 'when.time')
02-07 09:15:40.728 15913-15913/com.crossroad.ambulapp I/LiteCore [SQL]: Created prerecorded query enum with 0 rows (2 bytes) in 1.329ms
02-07 09:15:40.738 15913-16244/com.crossroad.ambulapp D/OpenGLRenderer: Render dirty regions requested: true
02-07 09:15:40.738 15913-16135/com.crossroad.ambulapp V/FA: Connection attempt already in progress
02-07 09:15:40.743 15913-15913/com.crossroad.ambulapp D/Atlas: Validating map...
02-07 09:15:40.748 15913-15913/com.crossroad.ambulapp I/LiteCoreJNI: [NATIVE] C4Replicator.getResponseHeaders() repl -> 0xe0318680
02-07 09:15:40.749 15913-15913/com.crossroad.ambulapp E/Sync: statusChanged() c4Status -> C4ReplicatorStatus{activityLevel=2, progressUnitsCompleted=0, progressUnitsTotal=0, progressDocumentCount=0, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:15:40.749 15913-15913/com.crossroad.ambulapp E/Sync: Replicator[<*> blip://192.168.1.16:4984/default_cluster] is connecting, progress 0/0, error: null
02-07 09:15:40.749 15913-15913/com.crossroad.ambulapp E/Sync: statusChanged() c4Status -> C4ReplicatorStatus{activityLevel=4, progressUnitsCompleted=0, progressUnitsTotal=0, progressDocumentCount=0, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:15:40.749 15913-15913/com.crossroad.ambulapp E/Sync: Replicator[<*> blip://192.168.1.16:4984/default_cluster] is busy, progress 0/0, error: null
02-07 09:15:40.814 15913-16244/com.crossroad.ambulapp I/OpenGLRenderer: Initialized EGL, version 1.4
02-07 09:15:40.814 15913-16244/com.crossroad.ambulapp W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
02-07 09:15:40.825 15913-16244/com.crossroad.ambulapp D/OpenGLRenderer: Enabling debug mode 0
02-07 09:15:40.999 15913-15913/com.crossroad.ambulapp D/REPLICATORSTATUS: BUSY
02-07 09:15:40.999 15913-15913/com.crossroad.ambulapp D/REPLICATORSTATUS: BUSY
02-07 09:15:41.107 15913-16244/com.crossroad.ambulapp V/RenderScript: Application requested CPU execution
02-07 09:15:41.111 15913-16244/com.crossroad.ambulapp V/RenderScript: 0xdff83e00 Launching thread(s), CPUs 4
02-07 09:15:41.136 15913-15913/com.crossroad.ambulapp W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
02-07 09:15:41.154 15913-16135/com.crossroad.ambulapp D/FA: Connected to remote service
02-07 09:15:41.154 15913-16135/com.crossroad.ambulapp V/FA: Processing queued up service tasks: 4
02-07 09:15:41.468 15913-16233/com.crossroad.ambulapp E/WebSocket: WebSocketListener.onMessage() bytes -> 020100
02-07 09:15:41.468 15913-16233/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.completedReceive() socket -> 0xebc74c48, byteCount -> 3
02-07 09:15:42.237 15913-16233/com.crossroad.ambulapp E/WebSocket: WebSocketListener.onMessage() bytes -> [HERE I REMOVE A SEQUENCE OF BITES BECAUSE I CAN'T UPDATE A REPLY WITH A LOT OF CHARACTERS]
02-07 09:15:42.238 15913-16230/com.crossroad.ambulapp I/LiteCore [Sync]: {DBWorker#2} Looking up 212 revisions in the db (seq '966'..'1834')
02-07 09:15:42.247 15913-16231/com.crossroad.ambulapp I/LiteCoreJNI: [NATIVE] C4Replicator.statusChangedCallback() repl -> 0x0xe0318680 status -> 4
02-07 09:15:42.248 15913-16231/com.crossroad.ambulapp E/C4Replicator: statusChangedCallback() handle -> 3761342080, status -> C4ReplicatorStatus{activityLevel=4, progressUnitsCompleted=0, progressUnitsTotal=12, progressDocumentCount=0, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:15:42.248 15913-15913/com.crossroad.ambulapp E/Sync: statusChanged() c4Status -> C4ReplicatorStatus{activityLevel=4, progressUnitsCompleted=0, progressUnitsTotal=12, progressDocumentCount=0, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:15:42.248 15913-15913/com.crossroad.ambulapp E/Sync: Replicator[<*> blip://192.168.1.16:4984/default_cluster] is busy, progress 0/12, error: null
02-07 09:15:42.248 15913-15913/com.crossroad.ambulapp D/REPLICATORSTATUS: BUSY
02-07 09:15:42.249 15913-16233/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.completedReceive() socket -> 0xebc74c48, byteCount -> 7756
02-07 09:15:42.249 15913-16230/com.crossroad.ambulapp I/LiteCore [Sync]: {DBWorker#2} Responding w/request for 12 revs
02-07 09:15:42.250 15913-16229/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.write() handle -> 0xebc74c48, allocatedData.length -> 1291
02-07 09:15:42.615 15913-16233/com.crossroad.ambulapp E/WebSocket: WebSocketListener.onMessage() bytes -> 02200e01006368616e67657300040005006e756c6c
02-07 09:15:42.615 15913-16233/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.completedReceive() socket -> 0xebc74c48, byteCount -> 21

02-07 09:15:42.645 15913-16233/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.completedReceive() socket -> 0xebc74c48, byteCount -> 486
02-07 09:15:42.676 15913-16232/com.crossroad.ambulapp I/LiteCore [Sync]: {DBWorker#2} Inserted 12 revs in 5.27ms (2275/sec)
02-07 09:15:42.677 15913-16229/com.crossroad.ambulapp I/LiteCoreJNI: [NATIVE] C4Replicator.statusChangedCallback() repl -> 0x0xe0318680 status -> 4
02-07 09:15:42.679 15913-16229/com.crossroad.ambulapp E/C4Replicator: statusChangedCallback() handle -> 3761342080, status -> C4ReplicatorStatus{activityLevel=4, progressUnitsCompleted=0, progressUnitsTotal=12, progressDocumentCount=1, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:15:42.680 15913-16230/com.crossroad.ambulapp I/LiteCore [Sync]: {Pull#4} now idle
02-07 09:15:42.681 15913-15913/com.crossroad.ambulapp E/Sync: statusChanged() c4Status -> C4ReplicatorStatus{activityLevel=4, progressUnitsCompleted=0, progressUnitsTotal=12, progressDocumentCount=1, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:15:42.682 15913-15913/com.crossroad.ambulapp E/Sync: Replicator[<*> blip://192.168.1.16:4984/default_cluster] is busy, progress 0/12, error: null
02-07 09:15:42.683 15913-15913/com.crossroad.ambulapp D/REPLICATORSTATUS: BUSY
02-07 09:15:42.684 15913-16229/com.crossroad.ambulapp I/LiteCore [Sync]: {Repl#1} now idle
02-07 09:15:42.684 15913-16229/com.crossroad.ambulapp I/LiteCoreJNI: [NATIVE] C4Replicator.statusChangedCallback() repl -> 0x0xe0318680 status -> 3
02-07 09:15:42.688 15913-16229/com.crossroad.ambulapp E/C4Replicator: statusChangedCallback() handle -> 3761342080, status -> C4ReplicatorStatus{activityLevel=3, progressUnitsCompleted=1, progressUnitsTotal=12, progressDocumentCount=12, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:15:42.688 15913-15913/com.crossroad.ambulapp E/Sync: statusChanged() c4Status -> C4ReplicatorStatus{activityLevel=3, progressUnitsCompleted=1, progressUnitsTotal=12, progressDocumentCount=12, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:15:42.689 15913-15913/com.crossroad.ambulapp E/Sync: Replicator[<*> blip://192.168.1.16:4984/default_cluster] is idle, progress 1/12, error: null
02-07 09:15:42.689 15913-15913/com.crossroad.ambulapp D/REPLICATORSTATUS: IDLE
02-07 09:15:42.708 15913-15913/com.crossroad.ambulapp I/LiteCore [SQL]: Compiling JSON query: {"WHAT":[["._id"],["."]],"ORDER_BY":[[".when.time"]],"WHERE":["AND",["AND",["=",[".type"],"Transport"],["=",[".car_id"],"car_2"]],["=",[".when.date"],"2018-02-08"]]}
02-07 09:15:42.708 15913-15913/com.crossroad.ambulapp I/LiteCore [SQL]: Compiled Query: SELECT key, fl_root(body) FROM kv_default WHERE ((fl_value(body, 'type') = 'Transport' AND fl_value(body, 'car_id') = 'car_2') AND fl_value(body, 'when.date') = '2018-02-08') AND (flags & 1) = 0 ORDER BY fl_value(body, 'when.time')
02-07 09:15:42.709 15913-15913/com.crossroad.ambulapp I/LiteCore [SQL]: Created prerecorded query enum with 0 rows (2 bytes) in 0.541ms
02-07 09:15:42.877 15913-16230/com.crossroad.ambulapp I/LiteCoreJNI: [NATIVE] C4Replicator.statusChangedCallback() repl -> 0x0xe0318680 status -> 3
02-07 09:15:42.881 15913-16230/com.crossroad.ambulapp E/C4Replicator: statusChangedCallback() handle -> 3761342080, status -> C4ReplicatorStatus{activityLevel=3, progressUnitsCompleted=1, progressUnitsTotal=12, progressDocumentCount=12, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:15:42.884 15913-15913/com.crossroad.ambulapp E/Sync: statusChanged() c4Status -> C4ReplicatorStatus{activityLevel=3, progressUnitsCompleted=1, progressUnitsTotal=12, progressDocumentCount=12, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:15:42.885 15913-15913/com.crossroad.ambulapp E/Sync: Replicator[<*> blip://192.168.1.16:4984/default_cluster] is idle, progress 1/12, error: null
02-07 09:15:42.904 15913-15913/com.crossroad.ambulapp D/REPLICATORSTATUS: IDLE
02-07 09:15:42.923 15913-15913/com.crossroad.ambulapp I/LiteCore [SQL]: Compiling JSON query: {"WHAT":[["._id"],["."]],"ORDER_BY":[[".when.time"]],"WHERE":["AND",["AND",["=",[".type"],"Transport"],["=",[".car_id"],"car_2"]],["=",[".when.date"],"2018-02-08"]]}
02-07 09:15:42.924 15913-15913/com.crossroad.ambulapp I/LiteCore [SQL]: Compiled Query: SELECT key, fl_root(body) FROM kv_default WHERE ((fl_value(body, 'type') = 'Transport' AND fl_value(body, 'car_id') = 'car_2') AND fl_value(body, 'when.date') = '2018-02-08') AND (flags & 1) = 0 ORDER BY fl_value(body, 'when.time')
02-07 09:15:42.927 15913-15913/com.crossroad.ambulapp I/LiteCore [SQL]: Created prerecorded query enum with 0 rows (2 bytes) in 1.720ms
02-07 09:15:46.359 15913-16135/com.crossroad.ambulapp V/FA: Inactivity, disconnecting from the service

Log sync:

2018-02-07T09:15:33.721+01:00 ==== Couchbase Sync Gateway/1.5.0(594;e78dbf1) ====
2018-02-07T09:15:33.721+01:00 Configured process to allow 5000 open file descriptors
2018-02-07T09:15:33.721+01:00 Opening db /default_cluster as bucket "omnitrace", pool "default", server <http://127.0.0.1:8091>
2018-02-07T09:15:33.721+01:00 GoCBCustomSGTranscoder Opening Couchbase database omnitrace on <http://127.0.0.1:8091> as user "root"
2018-02-07T09:15:34.127+01:00 Importing documents...
_time=2018-02-07T09:15:34.135+01:00 _level=INFO _msg=Using plain authentication for user root 
2018-02-07T09:15:34.171+01:00 Re-running sync function on all 0 documents...
2018-02-07T09:15:34.171+01:00 Finished re-running sync function; 0 docs changed
2018-02-07T09:15:34.171+01:00     Reset guest user to config
2018-02-07T09:15:34.171+01:00 Starting admin server on 127.0.0.1:4985
2018-02-07T09:15:34.177+01:00 Starting server on :4984 ...
2018-02-07T09:15:38.912+01:00 HTTP:  #001: GET /default_cluster/_blipsync
  1. Turn off the wifi and kill the app:

  2. add two documents

Sync gateway log:

2018-02-07T09:15:33.721+01:00 ==== Couchbase Sync Gateway/1.5.0(594;e78dbf1) ====
2018-02-07T09:15:33.721+01:00 Configured process to allow 5000 open file descriptors
2018-02-07T09:15:33.721+01:00 Opening db /default_cluster as bucket "omnitrace", pool "default", server <http://127.0.0.1:8091>
2018-02-07T09:15:33.721+01:00 GoCBCustomSGTranscoder Opening Couchbase database omnitrace on <http://127.0.0.1:8091> as user "root"
2018-02-07T09:15:34.127+01:00 Importing documents...
_time=2018-02-07T09:15:34.135+01:00 _level=INFO _msg=Using plain authentication for user root 
2018-02-07T09:15:34.171+01:00 Re-running sync function on all 0 documents...
2018-02-07T09:15:34.171+01:00 Finished re-running sync function; 0 docs changed
2018-02-07T09:15:34.171+01:00     Reset guest user to config
2018-02-07T09:15:34.171+01:00 Starting admin server on 127.0.0.1:4985
2018-02-07T09:15:34.177+01:00 Starting server on :4984 ...
2018-02-07T09:15:38.912+01:00 HTTP:  #001: GET /default_cluster/_blipsync
2018-02-07T09:16:36.789+01:00 HTTP:  #002: GET /default_cluster/_changes?since=1834&feed=continuous&heartbeat=30000
2018-02-07T09:17:37.410+01:00 HTTP:  #003: GET /default_cluster/
2018-02-07T09:17:37.416+01:00 HTTP:  #004: GET /default_cluster/_changes?since=0&feed=continuous&heartbeat=30000
2018-02-07T09:17:42.215+01:00 HTTP:  #005: POST /default_cluster/
2018-02-07T09:17:42.260+01:00 HTTP:  #006: PUT /default_cluster/78fd05668620e0d1f1bdc324e861b742?rev=1-9da88832a92e90df646716781101539a
2018-02-07T09:17:48.138+01:00 HTTP:  #007: GET /default_cluster/
2018-02-07T09:17:48.143+01:00 HTTP:  #008: GET /default_cluster/_changes?since=0&feed=continuous&heartbeat=30000
2018-02-07T09:17:49.703+01:00 HTTP:  #009: POST /default_cluster/
2018-02-07T09:17:49.711+01:00 HTTP:  #010: PUT /default_cluster/3307dd2b9795337995f1373a41a7ded7?rev=1-f5cffacda7357e8b46502b35fbd26868

Add the rest of the log:

  1. turn on the wifi and reopen the app
    The log not contains the inizialization’s part, which is the same of the previously log

02-07 09:20:19.715 16673-16673/com.crossroad.ambulapp E/Sync: Replicator[<*> blip://192.168.1.16:4984/default_cluster] is connecting, progress 0/0, error: null
02-07 09:20:19.724 16673-16699/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.open() socket -> 0xebc74c48, scheme -> blip, hostname -> 192.168.1.16, port -> 4984, path -> /default_cluster/_blipsync
02-07 09:20:19.726 16673-16699/com.crossroad.ambulapp E/C4Socket: optionsFleece: not null
02-07 09:20:19.730 16673-16699/com.crossroad.ambulapp E/C4Socket: options = {channels=[transports_company_id, car_2], auth={username=root, type=Basic, password=123456}, headers={User-Agent=CouchbaseLite/2.0.0-231 

02-07 09:20:20.380 16673-16703/com.crossroad.ambulapp E/WebSocket: WebSocketListener.onOpen() response -> Response{protocol=http/1.1, code=101, message=Switching Protocols, url=http://192.168.1.16:4984/default_cluster/_blipsync}
02-07 09:20:20.380 16673-16703/com.crossroad.ambulapp E/WebSocket: receivedHTTPResponse() httpStatus -> 101
02-07 09:20:20.381 16673-16703/com.crossroad.ambulapp I/LiteCore [BLIP]: {N8litecore4blip10ConnectionE#1} Connected!
02-07 09:20:20.381 16673-16699/com.crossroad.ambulapp I/LiteCore [Sync]: {Repl#1}==> N8litecore4repl10ReplicatorE ->blip:192.168.1.16:4984/default_cluster/_blipsync
02-07 09:20:20.381 16673-16699/com.crossroad.ambulapp I/LiteCore [Sync]: {Repl#1} BLIP Connected
02-07 09:20:20.381 16673-16699/com.crossroad.ambulapp I/LiteCore [Sync]: {Repl#1} now busy
02-07 09:20:20.381 16673-16699/com.crossroad.ambulapp I/LiteCoreJNI: [NATIVE] C4Replicator.statusChangedCallback() repl -> 0x0xe032e680 status -> 4
02-07 09:20:20.382 16673-16701/com.crossroad.ambulapp I/LiteCore [Sync]: {DBWorker#2}==> N8litecore4repl8DBWorkerE ->blip:192.168.1.16:4984/default_cluster/_blipsync
02-07 09:20:20.383 16673-16701/com.crossroad.ambulapp I/LiteCore [Sync]: {DBWorker#2} now idle
02-07 09:20:20.383 16673-16699/com.crossroad.ambulapp E/C4Replicator: statusChangedCallback() handle -> 3761432192, status -> C4ReplicatorStatus{activityLevel=4, progressUnitsCompleted=0, progressUnitsTotal=0, progressDocumentCount=0, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:20:20.383 16673-16699/com.crossroad.ambulapp I/LiteCore [Sync]: {Repl#1} Local checkpoint 'cp-N9riGjO8/fswtgMruH1N/aUdvUg=' is [231, '']; getting remote ...
02-07 09:20:20.384 16673-16695/com.crossroad.ambulapp D/FA: Logging event (FE): screen_view(_vs), Bundle[{firebase_event_origin(_o)=auto, firebase_screen_class(_sc)=MainActivity, firebase_screen_id(_si)=-6553170238754049111}]
02-07 09:20:20.385 16673-16702/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.write() handle -> 0xebc74c48, allocatedData.length -> 58
02-07 09:20:20.395 16673-16703/com.crossroad.ambulapp E/WebSocket: WebSocketListener.onMessage() bytes -> 01010c72657600302d3400040005007b226c6f63616c223a3233317d
02-07 09:20:20.395 16673-16703/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.completedReceive() socket -> 0xebc74c48, byteCount -> 28
02-07 09:20:20.395 16673-16701/com.crossroad.ambulapp I/LiteCore [Sync]: {Repl#1} Received remote checkpoint: '{"local":231}'
02-07 09:20:20.395 16673-16701/com.crossroad.ambulapp I/LiteCore [Sync]: {Repl#1} ...got remote checkpoint: [231, ''] rev='0-4'
02-07 09:20:20.395 16673-16701/com.crossroad.ambulapp I/LiteCore [Sync]: {Push#3}==> N8litecore4repl6PusherE ->blip:192.168.1.16:4984/default_cluster/_blipsync
02-07 09:20:20.395 16673-16701/com.crossroad.ambulapp I/LiteCore [Sync]: {Push#3} Starting continuous push from local seq 1
02-07 09:20:20.396 16673-16701/com.crossroad.ambulapp I/LiteCore [Sync]: {Push#3} Reading 200 changes since sequence 231 ...
02-07 09:20:20.396 16673-16701/com.crossroad.ambulapp I/LiteCore [Sync]: {Push#3} now busy
02-07 09:20:20.396 16673-16701/com.crossroad.ambulapp I/LiteCore [Sync]: {Pull#4}==> N8litecore4repl6PullerE ->blip:192.168.1.16:4984/default_cluster/_blipsync
02-07 09:20:20.396 16673-16701/com.crossroad.ambulapp I/LiteCore [Sync]: {Pull#4} Starting pull from remote seq 
02-07 09:20:20.396 16673-16701/com.crossroad.ambulapp I/LiteCore [Sync]: {Pull#4} now busy
02-07 09:20:20.396 16673-16701/com.crossroad.ambulapp I/LiteCore [Sync]: {DBWorker#2} Reading up to 200 local changes since #231
02-07 09:20:20.396 16673-16699/com.crossroad.ambulapp I/LiteCore [Sync]: {Push#3} Caught up, at lastSequence 231
02-07 09:20:20.396 16673-16699/com.crossroad.ambulapp I/LiteCore [Sync]: {Push#3} now idle
02-07 09:20:20.397 16673-16701/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.write() handle -> 0xebc74c48, allocatedData.length -> 109
02-07 09:20:20.400 16673-16701/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.write() handle -> 0xebc74c48, allocatedData.length -> 15
02-07 09:20:20.403 16673-16703/com.crossroad.ambulapp E/WebSocket: WebSocketListener.onMessage() bytes -> 020100
02-07 09:20:20.403 16673-16703/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.completedReceive() socket -> 0xebc74c48, byteCount -> 3
02-07 09:20:20.427 16673-16673/com.crossroad.ambulapp I/LiteCore [SQL]: Compiling JSON query: {"WHAT":[["._id"],["."]],"ORDER_BY":[[".when.time"]],"WHERE":["AND",["AND",["=",[".type"],"Transport"],["=",[".car_id"],"car_2"]],["=",[".when.date"],"2018-02-08"]]}
02-07 09:20:20.427 16673-16673/com.crossroad.ambulapp I/LiteCore [SQL]: Compiled Query: SELECT key, fl_root(body) FROM kv_default WHERE ((fl_value(body, 'type') = 'Transport' AND fl_value(body, 'car_id') = 'car_2') AND fl_value(body, 'when.date') = '2018-02-08') AND (flags & 1) = 0 ORDER BY fl_value(body, 'when.time')
02-07 09:20:20.430 16673-16673/com.crossroad.ambulapp I/LiteCore [SQL]: Created prerecorded query enum with 0 rows (2 bytes) in 1.564ms
02-07 09:20:20.438 16673-16695/com.crossroad.ambulapp V/FA: Connection attempt already in progress
02-07 09:20:20.438 16673-16713/com.crossroad.ambulapp D/OpenGLRenderer: Render dirty regions requested: true
02-07 09:20:20.444 16673-16673/com.crossroad.ambulapp D/Atlas: Validating map...
02-07 09:20:20.449 16673-16673/com.crossroad.ambulapp I/LiteCoreJNI: [NATIVE] C4Replicator.getResponseHeaders() repl -> 0xe032e680
02-07 09:20:20.449 16673-16673/com.crossroad.ambulapp E/Sync: statusChanged() c4Status -> C4ReplicatorStatus{activityLevel=2, progressUnitsCompleted=0, progressUnitsTotal=0, progressDocumentCount=0, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:20:20.449 16673-16673/com.crossroad.ambulapp E/Sync: Replicator[<*> blip://192.168.1.16:4984/default_cluster] is connecting, progress 0/0, error: null
02-07 09:20:20.449 16673-16673/com.crossroad.ambulapp E/Sync: statusChanged() c4Status -> C4ReplicatorStatus{activityLevel=4, progressUnitsCompleted=0, progressUnitsTotal=0, progressDocumentCount=0, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:20:20.449 16673-16673/com.crossroad.ambulapp E/Sync: Replicator[<*> blip://192.168.1.16:4984/default_cluster] is busy, progress 0/0, error: null
02-07 09:20:20.531 16673-16713/com.crossroad.ambulapp I/OpenGLRenderer: Initialized EGL, version 1.4
02-07 09:20:20.531 16673-16713/com.crossroad.ambulapp W/OpenGLRenderer: Failed to choose config with EGL_SWAP_BEHAVIOR_PRESERVED, retrying without...
02-07 09:20:20.543 16673-16713/com.crossroad.ambulapp D/OpenGLRenderer: Enabling debug mode 0
02-07 09:20:20.646 16673-16673/com.crossroad.ambulapp D/REPLICATORSTATUS: BUSY
02-07 09:20:20.646 16673-16673/com.crossroad.ambulapp D/REPLICATORSTATUS: BUSY
02-07 09:20:20.714 16673-16713/com.crossroad.ambulapp V/RenderScript: Application requested CPU execution
02-07 09:20:20.723 16673-16713/com.crossroad.ambulapp V/RenderScript: 0xdff84c00 Launching thread(s), CPUs 4
02-07 09:20:20.772 16673-16673/com.crossroad.ambulapp W/art: Before Android 4.1, method int android.support.v7.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView
02-07 09:20:20.788 16673-16695/com.crossroad.ambulapp D/FA: Connected to remote service
02-07 09:20:20.788 16673-16695/com.crossroad.ambulapp V/FA: Processing queued up service tasks: 4
02-07 09:20:20.910 16673-16703/com.crossroad.ambulapp E/WebSocket: WebSocketListener.onMessage() bytes -> [REMOVE A LOT OF BITES]
02-07 09:20:20.911 16673-16703/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.completedReceive() socket -> 0xebc74c48, byteCount -> 7918
02-07 09:20:20.914 16673-16699/com.crossroad.ambulapp I/LiteCore [Sync]: {DBWorker#2} Looking up 216 revisions in the db (seq '966'..'1842')
02-07 09:20:20.948 16673-16699/com.crossroad.ambulapp I/LiteCore [Sync]: {DBWorker#2} Responding w/request for 15 revs
02-07 09:20:20.949 16673-16702/com.crossroad.ambulapp I/LiteCoreJNI: [NATIVE] C4Replicator.statusChangedCallback() repl -> 0x0xe032e680 status -> 4
02-07 09:20:20.949 16673-16702/com.crossroad.ambulapp E/C4Replicator: statusChangedCallback() handle -> 3761432192, status -> C4ReplicatorStatus{activityLevel=4, progressUnitsCompleted=0, progressUnitsTotal=15, progressDocumentCount=0, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:20:20.950 16673-16673/com.crossroad.ambulapp E/Sync: statusChanged() c4Status -> C4ReplicatorStatus{activityLevel=4, progressUnitsCompleted=0, progressUnitsTotal=15, progressDocumentCount=0, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:20:20.950 16673-16673/com.crossroad.ambulapp E/Sync: Replicator[<*> blip://192.168.1.16:4984/default_cluster] is busy, progress 0/15, error: null
02-07 09:20:20.950 16673-16673/com.crossroad.ambulapp D/REPLICATORSTATUS: BUSY
02-07 09:20:20.951 16673-16700/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.write() handle -> 0xebc74c48, allocatedData.length -> 1304
02-07 09:20:20.967 16673-16703/com.crossroad.ambulapp E/WebSocket: WebSocketListener.onMessage() bytes -> 02200e01006368616e67657300040005006e756c6c
02-07 09:20:20.968 16673-16701/com.crossroad.ambulapp I/LiteCore [Sync]: {Pull#4} Caught up with remote changes
02-07 09:20:20.968 16673-16703/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.completedReceive() socket -> 0xebc74c48, byteCount -> 21

02-07 09:20:20.985 16673-16703/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.completedReceive() socket -> 0xebc74c48, byteCount -> 390
02-07 09:20:21.026 16673-16699/com.crossroad.ambulapp I/LiteCore [Sync]: {DBWorker#2} Inserted 15 revs in 3.91ms (3832/sec)
02-07 09:20:21.026 16673-16699/com.crossroad.ambulapp I/LiteCore [Sync]: {DBWorker#2} now busy
02-07 09:20:21.026 16673-16702/com.crossroad.ambulapp I/LiteCore [Sync]: {Pull#4} now idle
02-07 09:20:21.026 16673-16700/com.crossroad.ambulapp I/LiteCore [Sync]: {DBWorker#2} Notified of 2 db changes #232 ... #233
02-07 09:20:21.026 16673-16702/com.crossroad.ambulapp I/LiteCore [Sync]: {Repl#1} now idle
02-07 09:20:21.026 16673-16702/com.crossroad.ambulapp I/LiteCoreJNI: [NATIVE] C4Replicator.statusChangedCallback() repl -> 0x0xe032e680 status -> 3
02-07 09:20:21.027 16673-16700/com.crossroad.ambulapp I/LiteCore [Sync]: {DBWorker#2} now idle
02-07 09:20:21.027 16673-16700/com.crossroad.ambulapp I/LiteCore [Sync]: {Push#3} Read 2 changes: Pusher sending 'changes' with sequences 232 - 233
02-07 09:20:21.027 16673-16702/com.crossroad.ambulapp E/C4Replicator: statusChangedCallback() handle -> 3761432192, status -> C4ReplicatorStatus{activityLevel=3, progressUnitsCompleted=3, progressUnitsTotal=15, progressDocumentCount=15, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:20:21.028 16673-16700/com.crossroad.ambulapp I/LiteCore [Sync]: {Push#3} now busy
02-07 09:20:21.029 16673-16702/com.crossroad.ambulapp I/LiteCore [Sync]: {Repl#1} now busy
02-07 09:20:21.029 16673-16702/com.crossroad.ambulapp I/LiteCoreJNI: [NATIVE] C4Replicator.statusChangedCallback() repl -> 0x0xe032e680 status -> 4
02-07 09:20:21.029 16673-16701/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.write() handle -> 0xebc74c48, allocatedData.length -> 153
02-07 09:20:21.031 16673-16702/com.crossroad.ambulapp E/C4Replicator: statusChangedCallback() handle -> 3761432192, status -> C4ReplicatorStatus{activityLevel=4, progressUnitsCompleted=3, progressUnitsTotal=15, progressDocumentCount=15, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:20:21.043 16673-16673/com.crossroad.ambulapp I/LiteCore [SQL]: Compiling JSON query: {"WHAT":[["."],["._id"],["._sequence"]],"WHERE":["AND",["AND",["=",[".type"],"Duty"],["=",[".car_id"],"car_2"]],["OR",["IS",[".end.at"],null],["IS",[".end.at"],["MISSING"]]]]}
02-07 09:20:21.043 16673-16673/com.crossroad.ambulapp I/LiteCore [SQL]: Compiled Query: SELECT fl_root(body), key, sequence FROM kv_default WHERE ((fl_value(body, 'type') = 'Duty' AND fl_value(body, 'car_id') = 'car_2') AND (fl_value(body, 'end.at') IS x'' OR fl_value(body, 'end.at') IS NULL)) AND (flags & 1) = 0
02-07 09:20:21.045 16673-16673/com.crossroad.ambulapp I/LiteCore [SQL]: Created prerecorded query enum with 1 rows (1302 bytes) in 0.725ms
02-07 09:20:21.070 16673-16673/com.crossroad.ambulapp I/LiteCore [SQL]: Compiling JSON query: {"WHAT":[["._id"],["."]],"ORDER_BY":[[".when.time"]],"WHERE":["AND",["AND",["=",[".type"],"Transport"],["=",[".car_id"],"car_2"]],["=",[".when.date"],"2018-02-08"]]}
02-07 09:20:21.070 16673-16673/com.crossroad.ambulapp I/LiteCore [SQL]: Compiled Query: SELECT key, fl_root(body) FROM kv_default WHERE ((fl_value(body, 'type') = 'Transport' AND fl_value(body, 'car_id') = 'car_2') AND fl_value(body, 'when.date') = '2018-02-08') AND (flags & 1) = 0 ORDER BY fl_value(body, 'when.time')
02-07 09:20:21.072 16673-16673/com.crossroad.ambulapp I/LiteCore [SQL]: Created prerecorded query enum with 1 rows (322 bytes) in 1.012ms
02-07 09:20:21.149 16673-16701/com.crossroad.ambulapp I/LiteCoreJNI: [NATIVE] C4Replicator.statusChangedCallback() repl -> 0x0xe032e680 status -> 4
02-07 09:20:21.153 16673-16701/com.crossroad.ambulapp E/C4Replicator: statusChangedCallback() handle -> 3761432192, status -> C4ReplicatorStatus{activityLevel=4, progressUnitsCompleted=3, progressUnitsTotal=571, progressDocumentCount=15, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:20:21.198 16673-16700/com.crossroad.ambulapp I/LiteCore [Sync]: {DBWorker#2} Notified of 1 db changes #234 ... #234
02-07 09:20:21.199 16673-16673/com.crossroad.ambulapp E/Sync: statusChanged() c4Status -> C4ReplicatorStatus{activityLevel=3, progressUnitsCompleted=3, progressUnitsTotal=15, progressDocumentCount=15, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:20:21.199 16673-16673/com.crossroad.ambulapp E/Sync: Replicator[<*> blip://192.168.1.16:4984/default_cluster] is idle, progress 3/15, error: null
02-07 09:20:21.199 16673-16700/com.crossroad.ambulapp I/LiteCore [Sync]: {Push#3} Read 1 changes: Pusher sending 'changes' with sequences 234 - 234
02-07 09:20:21.199 16673-16673/com.crossroad.ambulapp E/Sync: statusChanged() c4Status -> C4ReplicatorStatus{activityLevel=4, progressUnitsCompleted=3, progressUnitsTotal=15, progressDocumentCount=15, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:20:21.199 16673-16673/com.crossroad.ambulapp E/Sync: Replicator[<*> blip://192.168.1.16:4984/default_cluster] is busy, progress 3/15, error: null
02-07 09:20:21.200 16673-16700/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.write() handle -> 0xebc74c48, allocatedData.length -> 106
02-07 09:20:21.229 16673-16701/com.crossroad.ambulapp I/LiteCoreJNI: [NATIVE] C4Replicator.statusChangedCallback() repl -> 0x0xe032e680 status -> 4
02-07 09:20:21.230 16673-16701/com.crossroad.ambulapp E/C4Replicator: statusChangedCallback() handle -> 3761432192, status -> C4ReplicatorStatus{activityLevel=4, progressUnitsCompleted=3, progressUnitsTotal=945, progressDocumentCount=15, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:20:21.257 16673-16673/com.crossroad.ambulapp E/Sync: statusChanged() c4Status -> C4ReplicatorStatus{activityLevel=4, progressUnitsCompleted=3, progressUnitsTotal=571, progressDocumentCount=15, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:20:21.258 16673-16673/com.crossroad.ambulapp E/Sync: Replicator[<*> blip://192.168.1.16:4984/default_cluster] is busy, progress 3/571, error: null
02-07 09:20:21.258 16673-16673/com.crossroad.ambulapp D/REPLICATORSTATUS: BUSY
02-07 09:20:21.259 16673-16673/com.crossroad.ambulapp D/REPLICATORSTATUS: BUSY
02-07 09:20:21.313 16673-16673/com.crossroad.ambulapp E/Sync: statusChanged() c4Status -> C4ReplicatorStatus{activityLevel=4, progressUnitsCompleted=3, progressUnitsTotal=945, progressDocumentCount=15, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:20:21.313 16673-16673/com.crossroad.ambulapp E/Sync: Replicator[<*> blip://192.168.1.16:4984/default_cluster] is busy, progress 3/945, error: null
02-07 09:20:21.313 16673-16673/com.crossroad.ambulapp D/REPLICATORSTATUS: BUSY
02-07 09:20:21.321 16673-16673/com.crossroad.ambulapp I/LiteCore [SQL]: Compiling JSON query: {"WHAT":[["."],["._id"],["._sequence"]],"WHERE":["AND",["AND",["=",[".type"],"Duty"],["=",[".car_id"],"car_2"]],["OR",["IS",[".end.at"],null],["IS",[".end.at"],["MISSING"]]]]}
02-07 09:20:21.322 16673-16673/com.crossroad.ambulapp I/LiteCore [SQL]: Compiled Query: SELECT fl_root(body), key, sequence FROM kv_default WHERE ((fl_value(body, 'type') = 'Duty' AND fl_value(body, 'car_id') = 'car_2') AND (fl_value(body, 'end.at') IS x'' OR fl_value(body, 'end.at') IS NULL)) AND (flags & 1) = 0
02-07 09:20:21.322 16673-16673/com.crossroad.ambulapp I/LiteCore [SQL]: Created prerecorded query enum with 1 rows (1302 bytes) in 0.211ms
02-07 09:20:21.331 16673-16673/com.crossroad.ambulapp I/LiteCore [SQL]: Compiling JSON query: {"WHAT":[["._id"],["."]],"ORDER_BY":[[".when.time"]],"WHERE":["AND",["AND",["=",[".type"],"Transport"],["=",[".car_id"],"car_2"]],["=",[".when.date"],"2018-02-08"]]}
02-07 09:20:21.331 16673-16673/com.crossroad.ambulapp I/LiteCore [SQL]: Compiled Query: SELECT key, fl_root(body) FROM kv_default WHERE ((fl_value(body, 'type') = 'Transport' AND fl_value(body, 'car_id') = 'car_2') AND fl_value(body, 'when.date') = '2018-02-08') AND (flags & 1) = 0 ORDER BY fl_value(body, 'when.time')
02-07 09:20:21.332 16673-16673/com.crossroad.ambulapp I/LiteCore [SQL]: Created prerecorded query enum with 1 rows (418 bytes) in 0.899ms
02-07 09:20:21.344 16673-16673/com.crossroad.ambulapp D/REPLICATORSTATUS: BUSY
02-07 09:20:21.349 16673-16702/com.crossroad.ambulapp I/LiteCoreJNI: [NATIVE] C4Replicator.statusChangedCallback() repl -> 0x0xe032e680 status -> 4
02-07 09:20:21.350 16673-16702/com.crossroad.ambulapp E/C4Replicator: statusChangedCallback() handle -> 3761432192, status -> C4ReplicatorStatus{activityLevel=4, progressUnitsCompleted=3, progressUnitsTotal=945, progressDocumentCount=15, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:20:21.366 16673-16673/com.crossroad.ambulapp E/Sync: statusChanged() c4Status -> C4ReplicatorStatus{activityLevel=4, progressUnitsCompleted=3, progressUnitsTotal=945, progressDocumentCount=15, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:20:21.366 16673-16673/com.crossroad.ambulapp E/Sync: Replicator[<*> blip://192.168.1.16:4984/default_cluster] is busy, progress 3/945, error: null
02-07 09:20:21.383 16673-16673/com.crossroad.ambulapp D/REPLICATORSTATUS: BUSY
02-07 09:20:21.390 16673-16703/com.crossroad.ambulapp E/WebSocket: WebSocketListener.onMessage() bytes -> 0419001f8b080000096e8800ff8a36d0318805040000ffff5855018205000000
02-07 09:20:21.391 16673-16703/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.completedReceive() socket -> 0xebc74c48, byteCount -> 32
02-07 09:20:21.398 16673-16703/com.crossroad.ambulapp E/WebSocket: WebSocketListener.onMessage() bytes -> 0519001f8b080000096e8800ff8a8e5632d24d334eb634493137344b3432324e493330b1344f31373731b634324831304f4b558ae58a05040000ffff0a97f11929000000
02-07 09:20:21.398 16673-16703/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.completedReceive() socket -> 0xebc74c48, byteCount -> 68
02-07 09:20:21.399 16673-16702/com.crossroad.ambulapp I/LiteCore [Sync]: {DBWorker#2} now busy
02-07 09:20:21.400 16673-16702/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.write() handle -> 0xebc74c48, allocatedData.length -> 761
02-07 09:20:21.413 16673-16703/com.crossroad.ambulapp E/WebSocket: WebSocketListener.onMessage() bytes -> 060100
02-07 09:20:21.413 16673-16703/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.completedReceive() socket -> 0xebc74c48, byteCount -> 3
02-07 09:20:21.414 16673-16701/com.crossroad.ambulapp I/LiteCore [Sync]: {DBWorker#2} now idle
02-07 09:20:21.414 16673-16701/com.crossroad.ambulapp I/LiteCore [Sync]: {Push#3} now idle
02-07 09:20:21.415 16673-16703/com.crossroad.ambulapp E/WebSocket: WebSocketListener.onMessage() bytes -> 12000e01006368616e67657300040005005b5b313834332c226639623134663461663938343230643933663737663431363737333635393538222c22332d34643762373831363334326365663031336133666230346538316161353666333465663762393666225d5d
02-07 09:20:21.415 16673-16703/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.completedReceive() socket -> 0xebc74c48, byteCount -> 105
02-07 09:20:21.415 16673-16701/com.crossroad.ambulapp I/LiteCore [Sync]: {Pull#4} now busy
02-07 09:20:21.415 16673-16701/com.crossroad.ambulapp I/LiteCore [Sync]: {DBWorker#2} Looking up 1 revisions in the db (seq '1843'..'1843')
02-07 09:20:21.415 16673-16701/com.crossroad.ambulapp I/LiteCore [Sync]: {DBWorker#2} Responding w/request for 0 revs
02-07 09:20:21.415 16673-16701/com.crossroad.ambulapp I/LiteCore [Sync]: {Pull#4} now idle
02-07 09:20:21.417 16673-16700/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.write() handle -> 0xebc74c48, allocatedData.length -> 30
02-07 09:20:21.550 16673-16701/com.crossroad.ambulapp I/LiteCoreJNI: [NATIVE] C4Replicator.statusChangedCallback() repl -> 0x0xe032e680 status -> 4
02-07 09:20:21.553 16673-16701/com.crossroad.ambulapp E/C4Replicator: statusChangedCallback() handle -> 3761432192, status -> C4ReplicatorStatus{activityLevel=4, progressUnitsCompleted=933, progressUnitsTotal=945, progressDocumentCount=16, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:20:21.554 16673-16673/com.crossroad.ambulapp E/Sync: statusChanged() c4Status -> C4ReplicatorStatus{activityLevel=4, progressUnitsCompleted=933, progressUnitsTotal=945, progressDocumentCount=16, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:20:21.554 16673-16673/com.crossroad.ambulapp E/Sync: Replicator[<*> blip://192.168.1.16:4984/default_cluster] is busy, progress 933/945, error: null
02-07 09:20:21.555 16673-16673/com.crossroad.ambulapp D/REPLICATORSTATUS: BUSY
02-07 09:20:25.898 16673-16695/com.crossroad.ambulapp V/FA: Inactivity, disconnecting from the service
02-07 09:20:26.392 16673-16699/com.crossroad.ambulapp I/LiteCore [Sync]: {Repl#1} Saving remote checkpoint cp-N9riGjO8/fswtgMruH1N/aUdvUg= with rev='0-4' ...
02-07 09:20:26.395 16673-16699/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.write() handle -> 0xebc74c48, allocatedData.length -> 79
02-07 09:20:26.469 16673-16703/com.crossroad.ambulapp E/WebSocket: WebSocketListener.onMessage() bytes -> 07010872657600302d3500
02-07 09:20:26.469 16673-16703/com.crossroad.ambulapp E/C4Socket: C4Socket.callback.completedReceive() socket -> 0xebc74c48, byteCount -> 11
02-07 09:20:26.470 16673-16701/com.crossroad.ambulapp I/LiteCore [Sync]: {Repl#1} Successfully saved remote checkpoint cp-N9riGjO8/fswtgMruH1N/aUdvUg= as rev='0-5'
02-07 09:20:26.472 16673-16701/com.crossroad.ambulapp I/LiteCore [Sync]: {DBWorker#2} Saved local checkpoint cp-N9riGjO8/fswtgMruH1N/aUdvUg= to db
02-07 09:20:26.472 16673-16701/com.crossroad.ambulapp I/LiteCore [Sync]: {Repl#1} now idle
02-07 09:20:26.472 16673-16701/com.crossroad.ambulapp I/LiteCoreJNI: [NATIVE] C4Replicator.statusChangedCallback() repl -> 0x0xe032e680 status -> 3
02-07 09:20:26.476 16673-16701/com.crossroad.ambulapp E/C4Replicator: statusChangedCallback() handle -> 3761432192, status -> C4ReplicatorStatus{activityLevel=3, progressUnitsCompleted=933, progressUnitsTotal=945, progressDocumentCount=16, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:20:26.476 16673-16673/com.crossroad.ambulapp E/Sync: statusChanged() c4Status -> C4ReplicatorStatus{activityLevel=3, progressUnitsCompleted=933, progressUnitsTotal=945, progressDocumentCount=16, errorDomain=0, errorCode=0, errorInternalInfo=0}
02-07 09:20:26.477 16673-16673/com.crossroad.ambulapp E/Sync: Replicator[<*> blip://192.168.1.16:4984/default_cluster] is idle, progress 933/945, error: null
02-07 09:20:26.477 16673-16673/com.crossroad.ambulapp D/REPLICATORSTATUS: IDLE
02-07 09:20:26.498 16673-16673/com.crossroad.ambulapp I/LiteCore [SQL]: Compiling JSON query: {"WHAT":[["._id"],["."]],"ORDER_BY":[[".when.time"]],"WHERE":["AND",["AND",["=",[".type"],"Transport"],["=",[".car_id"],"car_2"]],["=",[".when.date"],"2018-02-08"]]}
02-07 09:20:26.498 16673-16673/com.crossroad.ambulapp I/LiteCore [SQL]: Compiled Query: SELECT key, fl_root(body) FROM kv_default WHERE ((fl_value(body, 'type') = 'Transport' AND fl_value(body, 'car_id') = 'car_2') AND fl_value(body, 'when.date') = '2018-02-08') AND (flags & 1) = 0 ORDER BY fl_value(body, 'when.time')
02-07 09:20:26.503 16673-16673/com.crossroad.ambulapp I/LiteCore [SQL]: Created prerecorded query enum with 1 rows (418 bytes) in 3.606ms

My Database class

...
private MyDatabase() {
        try {
            DatabaseConfiguration config = new DatabaseConfiguration(MyApplication.getInstance().getContext());
            mDatabase = new Database(DATABASE_NAME, config);
            mDatabase.addChangeListener(new DatabaseChangeListener() {
                @Override
                public void changed(DatabaseChange change) {
                    if (mListener != null) mListener.databaseChanged(change);
                }
            });

            mDatabase.createIndex("TypeIndex",
                    Index.valueIndex(ValueIndexItem.property("type"))
            );

            setReplicator();
        } catch (CouchbaseLiteException e) {
            e.printStackTrace();
        }
    }

    public static MyDatabase getInstance() {
        if (INSTANCE == null) {
            INSTANCE = new MyDatabase();
        }

        return INSTANCE;
    }

    public void stopReplication() {
        mIsReplicationStoppedForLogout = true;
        mReplicator.stop();
    }
    private ActivityLevel getReplicationStatus() {
        return mReplicatorStatus;
    }
    public boolean isReplicationFinish() {
        return getReplicationStatus() == ActivityLevel.IDLE;
    }
    public static int getReplicatorPercentageCompleteness(ReplicatorChange change) {
        if (change.getStatus().getProgress().getTotal() == 0) return 0;
        return (int) ((change.getStatus().getProgress().getCompleted() * 100) / change.getStatus().getProgress().getTotal());
    }
    public void updateReplicator() {
        if (mReplicator != null) mReplicator.stop();
        setReplicator();
    }
    private void setReplicator() {
        if (Company.isLoggedIn()) {
            try {
                URI uri = new URI(REPLICATION_URL);

                ReplicatorConfiguration replConfig = new ReplicatorConfiguration(mDatabase, uri);
                replConfig.setContinuous(true);

                List<String> channels = getChannels();
                replConfig.setChannels(channels);

                Authenticator auth = new BasicAuthenticator("root", "123456");
                replConfig.setAuthenticator(auth);
                mReplicator = new Replicator(replConfig);
                mReplicator.addChangeListener(new ReplicatorChangeListener() {
                    @Override
                    public void changed(ReplicatorChange change) {
                        mReplicatorStatus = change.getReplicator().getStatus().getActivityLevel();
                        Log.d("REPLICATORSTATUS", mReplicatorStatus.toString());
                        if (mListener != null) mListener.replicationRunning(change);
                        if (isReplicationFinish()) {
                            if (mListener != null) mListener.replicationFinished(change);
                        } else if (mReplicatorStatus == ActivityLevel.STOPPED) {
                            if (mIsReplicationStoppedForLogout) {
                                //mReplicator.removeChangeListener();
                                mIsReplicationStoppedForLogout = false;
                                deleteDatabase();
                            }
                        }
                    }
                });
                mReplicator.start();
            } catch (URISyntaxException e) {
                e.printStackTrace();
            }
        }
    }
...

On database change i run this query

Query query = Query.select(SelectResult.expression(Meta.id), SelectResult.all())
                .from(DataSource.database(MyDatabase.getInstance().getDatabase()))
                .where(
                        Expression.property(TYPE_FIELD_NAME).equalTo(DOC_TYPE));

it returns only one row, the first one.

Thank you for the logs.

One more thing to capture -
In your changed callback, can you log the documentIds in the change object ?

And if I understand, if you updated the 2nd doc on SGW, it shows up ?

I logged the change.getDocumentIDs() and it returns only the first document’s id, so the second document is not pulled at all.

Yes, if i update it, it shows up immediately, and the change listener logs the id.

Also, i tried to update the first document (which is already pulled to my device) when it is offline, and the change is not pulled too.
Online works perfect, though.

hmmm… Not sure if I am missing something in the logs that’s not obvious. I have filed a GitHub ticket. Can you update the ticket with the details you posted here please . Also to keep the ticket length manageable, it would be better if you included a gist of the logs and add the link to gist.

It is possible that this issue fixed with latest 2.0 where certain replication issues were fixed but it will be a few days before it will be available.

Thanks for adding details to ticket. I just noticed that in haste, I had pointed you to the wrong one …My bad. It was https://github.com/couchbase/couchbase-lite-android/issues/1586 . Its being tracked now

Hi @spruzzi23 and @priya.rajagopal

I wrote the unit test to reproduce this problem. However, I can not reproduce the problem. I am using a build from master branch which is almost equivalent to DB022. Could you please review unit test?