Hello,
I am working on our sync function for our database.
However, I’m finding that it doesn’t process all of the documents.
For some simple testing, my sync function is simply:
function(doc) { channel(‘test’); }
If I run this query on the database
select count(*) as c from test where meta().id not like “_sync%”
I get the following result:
[
{
“c”: 318828
}
]
However, after I run a database resync, I get the following results when I ping the _resync endpoint:
{
“status”: “completed”,
“start_time”: “2026-03-17T21:20:02.123154357Z”,
“last_error”: “”,
“resync_id”: “1b72dd73-9d7c-45c5-aa94-69c359ac928e”,
“docs_changed”: 159510,
“docs_processed”: 159510,
“collections_processing”: {
“_default”: [
“_default”
]
}
}
This means that even though I have 318,828 documents in the database, only 159,510 were processed through the sync function. Why are nearly half of them getting skipped? It’s not like the channels weren’t updated, it’s that they weren’t even processed at all.
Here is one such document, when I call it from the _raw end point using the Sync Gateway:
{
“_id”: “00013be8-c790-48d3-b7d4-c7654665d8b5”,
“_rev”: “1-1ae3f19e282d776283d90c740ed8aa50”,
“organization”: “MyOrganization”,
“sourceInstance”: “00013be8-c790-48d3-b7d4-c7654665d8b5”,
“title”: {
“fieldType”: “text”,
“titleTextSize”: “large”,
“value”: “Title Here”,
“valueTextSize”: “large”
},
“type”: “_view”,
“_xattrs”: {
“_sync”: null,
“_globalSync”: null,
“_vv”: null,
“_mou”: null,
“$document”: {
“CAS”: “0x18892de139350000”,
“datatype”: [
“snappy”,
“json”
],
“deleted”: false,
“exptime”: 0,
“flags”: 0,
“last_modified”: “1767994774”,
“revid”: “1”,
“seqno”: “0x000000000000028a”,
“value_bytes”: 1189,
“value_crc32c”: “0x416c7080”,
“vbucket_uuid”: “0x000006ea65895c82”
}
}
}
There’s nothing I can see that’s particularly different about this document. But the _sync value is staying as null after the sync function is run. So, this document is completely skipped.
Is there a reason? What can I do to make the sync function resync all documents?
Thanks