I’m facing issues where deleted docs are reappearing after a time in my bucket. I suspect it has something to do with my sync gateway but I’m unsure where to even start troubleshooting here.
Current Versions
- Couchbase Server Community Edition 7.0.2 build 6703
- couchbase-lite-android:2.8.6
- sync-gateway:2.8.3-community
I have three types of docs:
- config - Generated and edited on server but only sync down to devices
- device_generated - Generated on devices, only sync up to server
- server_generated - Generated and edited on server, never sync down to devices
Here is a illustration of the flow:
Sync gateway config
{
"log": [
"*"
],
"interface": "0.0.0.0:5500",
"adminInterface": "0.0.0.0:5501",
"databases": {
"bucket": {
"server": "node1.cluster",
"bucket": "bucket_name",
"username": "username",
"password": "password",
"enable_shared_bucket_access": true,
"import_docs": "continuous",
"use_views": true,
"users": {
"username": {
"password": "password",
"admin_channels": [
"*"
],
"disabled": false
}
},
"sync":
`
function sync(doc, oldDoc) {
/* sanity check */
// check if document was removed from server or via SDK
// In this case, just return
if (isRemoved()) {
return;
}
//Only sync documents that are created on the server
if (doc.type == "device_generated") {
channel("server");
} else {
channel("devices");
}
// This is when document is removed via SDK or directly on server
function isRemoved() {
return (isDelete() && oldDoc == null);
}
function isDelete() {
return (doc._deleted == true);
}
}
`
}
}
}
On Couchbase Lite I’ve setup my Android app to only sync on the “devices” channel.
Here is the problem I’m facing:
- device_generated and server_generated docs are being deleted by users on the server
- The docs are no longer present on the server
- A few days later they magically reappear
Can anyone suggest a reason why this might be happening? Is there an issue in my sync gateway config file?
Thanks in advance!