Sync gateway to sync gateway stops syncing even if one document is rejected by sync function

Hi @househippo,

We have a expiry time in each document, this expiry time is in epoch. If the time has expired then we reject the document using sync function.

Sync gateway to sync gateway sync stops as soon as one document in the pipeline is rejected by the sync gateway. It goes into a loop where it will not continue syncing any document further.

We need to stop taking the document because we purge them, hence having minimum number of required document in the bucket. So the documents according to business rule will never come back after the purge. And even if they come the data is useless.

What is the workaround to not to stop sync. Is marking them _deleted is the only solution for this. If yes then will tombstone will also be cleared from the application automatically or a compact function call will be required.

Regards
Pankaj Sharma

@pankaj.sharma,

Sounds like Sync Gateway is not invalidating its cache after a document has expired and SG-Replicate is stuck b/c _changes says the document should be processed. Could you raise an issues on https://github.com/couchbase/sync_gateway/issues

the expiry is not the standard TTL. It is a cusom field in which we put date time in EPOCH after which updates of these documents will be discarded on the sync gateway and following is the sync function for the same we are using

function(doc,oldDoc)
{
var d = new Date();
var n = d.getTime();
if(doc.ExpiryDateEpoch!=null)
{
if(n >= doc.ExpiryDateEpoch)
{
throw( { forbidden: “Document Expired” } );
}
}
channel(doc.channels);
}

now in when the SG to SG replicate starts then this issue comes even if one of the document whose ExpiryDateEpoch has crossed is rejected by the function.

Does it a valid issue?

Regards
Pankaj Sharma

SG-Replicate doesn’t understand the above throw error.

So what should be the error thrown , and can be understood by SG Replicate.

Could you create an issue and link back to this post.