How to locally delete already replicated documents to the cluster

Hi,

We’re having an issue on our android application.
The replicator config is continuous and push only with auto purge disabled

We created a listener to delete documents that were replicated successfully to the cluster.

But we’re seeing documents getting replicated to the cluster multiple times, so the local deletion doesn’t seem to properly work.

Here’s the code we are using for the deletion :

replicator.addDocumentReplicationListener(replication -> {
    if (replication.isPush()) {
        for (ReplicatedDocument document : replication.getDocuments()) {
            CouchbaseLiteException err = document.getError();
            if (err == null){
                try {
                    if (!replicator.isDocumentPending(document.getID())) {
                        database.purge(document.getID());
                    }
                } catch (CouchbaseLiteException e) {
                    e.printStackTrace();
                }
            }
        }
    }
});

Is there a better way to make sure that the documents are locally deleted once replicated?

Thank you in advance

I forgot to say that we start the replicator with the reset checkpoints option to true.

And we have a webhook to delete documents from the cluster.
Could that possibly be the cause of the documents getting replicated multiple times? Even with a push only configuration?

We added this option to fix a issue we faced when switching networks while the documents were getting replicated.

A purged document will never replicate again so if you are deleting on the server side, then I’d guess you are getting the document back again from another device that has not pushed the document yet.

Hi,

Thank you for the reply.
The documents are only created once by different users.
And since we are in push only mode, they are probably not getting purged correctly.

Is there any way the reset checkpoints option could cause the documents to be replicated again, even if they are purged?

Thank you very much.

Purging documents deletes all traces of the documents very destructively. Not even a reset checkpoint will get them back.