.net.net-coretransactionscouchbase

Recommended way for deleting "_txn" documents from Couchbase?


I have a .NET 6 application that uses transactions to modify documents in a Couchbase bucket, but each time a transaction runs, a new _txn document is created under the _default collection:

enter image description here

Question: Is it recommended to delete these files and which would be the correct way of doing it without affecting transactions that could be currently in progress?

The cleanup configurations are set to their default values

https://docs.couchbase.com/dotnet-sdk/current/concept-docs/transactions-cleanup.html

But what I understood from the documentation is that it cleans only transactions that failed for any given reason and were not committed or rolled back and only cleans the "_txn" files, but doesn't delete them.


Solution

  • All _txn: documents are internal metadata used for tracking active transactions, and the application should not modify them as it will impact any active transactions. This is called out in a couple of places in the documentation: 1, 2, 3.

    They grow only to a finite bounded set of documents - with default settings it's 1025 - and there is no need to manually delete them.

    They exist in the default collection for convenience, but the custom metadata collection feature can be used to store them elsewhere if desired.