Automatic purge of unused blobs

Hello,

I have a Couchbase and Sync Gateway instance and my clients are working on mobile devices with the CouchbaseLite. They upload a lot of attachments (blobs) over the Sync Gateway. Theses blobs are stored as binary documents in the Couchbase. (Docs: cbl-blobs)

The Problem is that I am not sure if these binary documents are automatically purged when the releated document is deleted/purged from the Couchbase.

So what do I have to do:

  1. Nothing. They are automatically purged when the related document is deleted/purged
  2. Run a Compaction on the bucket. The Compaction will remove all unused binary documents
  3. Always manually remove all attachments from a document via the Sync-Gw API before removing the document
  4. Nothing. They are automatically purged after the tombstone interval of the related document

I hope someone can help me and thank you in advance.

I can answer that on the local side, unless you delete the database, the answer is 2. Someone else will have to answer if you are asking about what to do on the server side (which it seems like you are)

Yes I am asking on the Server side. The used RAM of the Bucket increases every month by 1 GB and that worries me.

On the local side I already run a compaction maintainance after a CouchbaseLite instance is opened. (Summary: Compact the database file and delete unused attachments.)

Ok I pinged someone else, but it was a bit confusing that you said “stored as binary in the Couchbase” (meaning Server) and then linking to Couchbase Lite docs.

What version of Sync Gateway are you using? The behaviour differs depending on whether it’s 2.x or 3.x.

We are using the following:

Couchbase: Community Edition 7.2.4 build 7070
Sync Gateway: Couchbase Sync Gateway/3.1.6(5;301297c) CE

Since there was no update on this topic.
I wrote a query to check if there any unrelated attachments on the Server.

SELECT
  META(b).id AS binaryDocId
FROM `_default` AS b
UNNEST (SELECT RAW ARRAY_FLATTEN(
        ARRAY_AGG(ARRAY v.digest FOR v IN OBJECT_VALUES(META(d).xattrs._sync.attachments) END),
    1)
    FROM `_default` AS d
    WHERE META(d).xattrs._sync.attachments IS NOT MISSING) att
WHERE META(b).type = 'base64'
AND META(b).id LIKE '_sync:att2%'
AND SUBSTR(META(b).id, -33) NOT IN att;

From my point of view it seems like that the Sync Gateway automatically removes all binary documents (attachments) if the parent document is deleted.

if i am correct sync gateway >3, if the parent is deleted, attachments also gets deleted automatically.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.