Incorrect Document count in Couchbase sync gateway

Hello,

We need your help on one issue where we are not getting correct number of documents in Couchbase sync gateway. We have created channels with smaller number of documents based on document property “TYPE”.

“sync”: function (doc, oldDoc) { channel(doc.TYPE ); }

It is creating channels with name as doc.TYPE. However after making these changes, when we restart Couchbase sync gateway we get different and incorrect counts of document in configured channels every time. We are getting this issue even when channel size is very small and have less than 15 documents. For example we have 12 docs as TYPE TestType however we are getting only 3 documents in TestType channel.
We have created the Couchbase server with 1 node by using cbtransfer command.
We are using windows 10, 16 GB ram and i5 processor. We are using couchbase-server-enterprise_6.5.1 and couchbase-sync-gateway-enterprise_2.7.3_x86_64 for this development.

PFB the updated sync config code.

{
“adminInterface”: “:4985”,
“interface”: “0.0.0.0:4984”,
“log”: [""],
“databases”: {
“db”: {
“server”: “http://localhost:8091”,
“bucket”: “myBucket”,
“username”: “UserName”,
“password”: “**************”,
“enable_shared_bucket_access”: true,
“import_docs”: true,
“num_index_replicas”: 0,
“users”: {
“GUEST”: { “disabled”: false, “admin_channels”: ["
"] }
},
“sync”: `function (doc, oldDoc) {
channel(doc.TYPE );

  }`
}

}

It is creating channels with name as doc.TYPE. However after making these changes, when we restart Couchbase sync gateway we get different and incorrect counts of document in configured channels every time.

How are you verifying the number of documents in a channel ? And if you made changes to the sync function, you will have to do a resync if you are changing the access rules associated with existing documents .

I am manually counting the records in each channels present from below URL
http://localhost:4985/_admin/db/db/channels

Also it shows total number of documents in all channels in below URL
http://localhost:4985/db/_all_docs

Please let me know if i am missing something

Also let me know how to resync. I have restarted couchbase syn gateway service from windows services.

Use the resync endpoint. Also make sure you read the section on resync - you have to take database offline first. Also that section describes conditions under which resync needs to run

Troubleshooting tip - If there are documents that are there not getting imported, check the sync gateway logs

Thanks for reply.

I have checked with resync, however it is still showing wrong count.
I also check in logs, but could not find any clue. Can you please tell me if I need to check for any specific details in logs

In the other thread (where you reposted), you mentioned that you were observing the same indexing issues ? Please include complete log output

Hi Priya,

That indexing issue is occasional and does not come always . it is occurring on one of server, so we can ignore if for now. On other servers we are not seeing this issue.