Purging docs from CB cluster

Hi everyone,

I plan to implement a cleanup service for our CB cluster and I want to make sure I’m doing this right.

Basically, we use CB for a mobile app and never done any purging. Due to the nature of our app CB nodes contain a lot of docs that can be purged. More specifically docs that only exist as children of other docs and no longer referenced by any parent docs.

My plan is to write a service that listens for CB changes and builds lists of docs that can be safely purged. All listening/ purging will be done via the SGs.

The reason we want to do this housekeeping server-side is to avoid bugs on individual platforms. Is that the right approach? Is there a better way to do this?

Also, I have two questions regarding purging docs:

  1. If a doc is purged and then a mobile device pushes a new rev for that doc, what will happen? is it just an error that will be ignored (i.e the rev will be ignored as the parent rev is missing) or will it affect further syncing in some other way?

  2. Server-side, are purges replicated across CB nodes? i.e. if I issue a purge request to a SG connected to a CB node, will other CB nodes (connected to their own SGs) receive it -or- do I have to issue the request on each one of the SGs for each of CB nodes?

Thank you!

Even if a doc is purged on server, if clients have the doc and sync it up, it will be resurrected.

If you want a document to be completely purged from system (server and mobile apps), then you have couple of options

  • Remove unwanted documents from user channels (in addition to removing docs on the server). Removal of documents from user channels will trigger an accessRemoved message sent to clients that will in turn trigger an auto purge on clients
  • Delete the obsolete documents on server instead of purging. Deletes get synchronized to connected clients . When clients get deleted documents they can do a local purge as described here. With shared bucket access enabled, deletes are auto purged after metadata purge interval period on server .
  • When you are purging the documents on server, you can also add a “command document” that is synced over to all connected clients (over a dedicated command channel for instance) instructing it to purge specific set of documents
  • Implement Pattern 3 in this blog

Thank you Priya, I appreciate the detailed reply. I’ll have a look