Missed document after sync with sync-gateway

I have couchbase 6.6 and sync-gateway 3.1. After sync I got 22 documents instead of 38 that visible via couchbase web interface (I used GUEST without any password).

Then I dump and restore database to another server and got all 38 documents after sync.

I compare documents that missed in the first case and avaible in the second case,
all meta data and content are the same, config of sync-gateway also the same.

Client code:

    CBLEndpoint* targetEndpoint = CBLEndpoint_CreateWithURL(FLSTR("ws://server1:4984/test"), &err);
    if(!targetEndpoint) {
        return EXIT_FAILURE;
    }
    CBLReplicatorConfiguration replConfig;
    memset(&replConfig, 0, sizeof(replConfig));
    replConfig.database = database;
    replConfig.endpoint = targetEndpoint;
    replConfig.continuous = true;
    replConfig.replicatorType = kCBLReplicatorTypePull;

    CBLReplicator* replicator = CBLReplicator_Create(&replConfig, &err);
    CBLEndpoint_Free(targetEndpoint);
    if(!replicator) {
        return EXIT_FAILURE;
    }
    CBLReplicator_Start(replicator, false);
    printf("start sync\n");
    sleep(10);
    stop_replicator(replicator);

Any idea how to debug this problem?

Have you tried waiting for longer, or a retry loop based on how many docs you have locally?

It’s possible that the first time you replicate the documents aren’t cached in SG and so may take longer than 10s for initial query, retrieval and caching.

If you have any SG logs that might reveal what state the replication was in when the client stopped it.

Thanks for answer.

I check manually that my program writes every time:

info: CBLReplicator status: idle, progress=…/…, flag=2, error=0/0 (effective status=idle, completed=1.00%, docs=…)

before replicator stopped, so I am sure that this is not the case, replication is completed.

I can not see any stopage in sync_gateway, when I got all documents after sync from server2 or when I got 22/38 I can not see any indicator that all done, may be only empty message at the end:

[DBG] WSFrame+: c:#447 Sending frame: MSG#2486~ (flags= 101000, size= 6525)

So for me it looks like on server1 sync_gateway thinks that it has 22 documents and that’s all.

So I need some way to see what set of documents sync_gateway get from couchbase,
but I can not see even document id in sg_debug.log .

I found that sync-gateway 2.5 with the same database running in paralell,
works just fine. I recieve all documents from server1:5984 (sync-gateway 2.5), and only 22 from server1:4984 (sync-gateway 3.1).

Can you confirm what version of Sync Gateway you are running again please?
The latest released version of Sync Gateway is 3.0.0

The debug logs should show the number of changes being proposed to the client, and the each individual doc ID and rev ID if/when they are sent.

I tried three versions of sync-gateway:

  • build from source code 3.1
  • from rpm 3.0
  • build from source code 2.5 long time ago

the first one reports such version:

{"name":"Couchbase Sync Gateway","version":"3.1"},"version":"Couchbase Sync Gateway/() CE"}

3.0 and 3.1 show the same behaviour.

But I almost solved problem, and it is not strictly related to sync-gateway,
problem that couchbase query that sync-gateway send to server works in wrong way.

But when I fight with forum formatting, auto-spam system hide my topic about misfunctional N1QL query.
Can you unblock my topic, or move it here, because of I have no access to it anymore, thanks to Akismet.

Sorry for the over-zealous bot, I’ve undeleted your other post now. Thanks for digging into the query issue, it definitely looks odd. I’ll get somebody from the query team to take a look and see if they have any ideas.

I was a bit confused by the 3.1 version since it’s a branch in active development :smile: There are no guarantees that will be safe to compile and use until we decide to create a beta/RC/release from it.