How to remove tombstone in CBL 1.4.1

Hi All,

We get a lot of documents whose life time is very short. These documents are expired on server hence sends _deleted to the devices. This create a huge pile of tomb stone documents in the device, which need removal.

We have tried purging documents in database change listener but i went into a loop. Doing this in pull Replication change listener made the sync slower. Is there any other way to handle this.

Use the change listener to set the tombstone’s expiration time to something reasonably short, like an hour.

setting TTL in change listener does slow down the sync. And TTL is having a bug which have been filed.

Thanks to @househippo

He provided a way to get all documents, including the deleted ones. This query can be fired according to business requirement.

We used following query to remove the tombstone.

getQueryForPurge(){
Query query;
query = mydatabase.createAllDocumentsQuery();
query.setAllDocsMode(Query.AllDocsMode.INCLUDE_DELETED);
}

private void purgeDocumentsFromDB(){
int purgedCount = 0;
try {
QueryEnumerator queryEnumerator = getQueryForPurge().run();
for (QueryRow queryRow : queryEnumerator) {
try {
Document doc =queryRow.getDocument();
if(doc!=null) {
if (doc.isDeleted() == true || doc.getCurrentRevision()== null) {
doc.purge();
purgedCount++;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}

    }catch (CouchbaseLiteException ex){
        ex.printStackTrace();
    }
}

The point now is to have a function which can only get the deleted document and purge them and delete tombstone in one function call.

I am thinking of creating the function in couchbase lite, test and provide a pull request.

You are welcome to make a pull request but FYI I am not sure it will be accepted because there are no more API changes planned for 1.x now that 2.0 is out.

What about customers who are still using 1.x and cant update their app because of following reasons.

  1. 2.x are breaking changes. The app almost need to be re -written.
  2. Delivery time is there or almost passed.
  3. No support of java
  4. No custom merge based conflict resolution.
  5. No encryption when GDPR compliance are on your head.
  6. No P2P when you have committed P2P to client at the time of choosing couch-base as the solution partner. Even worse when the Client have brought the enterprise licenses.
  7. Without getting ROI, for the money put on Map Reduce, 1.x and then convert the whole Enterprise level app into something new which is altogether an unknown zone.

there can be many other reasons. But then knowing that no more pull requests will be entertained for 1.x is heart breaking. Even after having enterprise level license the customer is willing to do so.

:frowning:

Enterprise requests are treated with higher priority so rest assured they won’t be simply shut down. I’m referring to straight up pull requests with no other context, so sorry for alarming you.