Search code examples
google-cloud-datastore

Firestore (Datastore mode) - how many writes are billed if a transaction is rolled-back?


Can anyone shed some light on how billing works in Firestore (Datastore mode) when a transaction is rolled back? How many writes is one going to be billed if one batch deletes 500 entities (DeleteMulti) then rolls back the transaction?


Solution

  • From a billing/quota perspective, operations are tracked exactly the same in a transaction regardless of whether the transaction succeeds and is committed, or rolled back.

    This means that if a you attempts to create 5 items, then delete 2 existing ones, then create one more, they will be charged for 6 write operations and 2 deletes. This will be the case if the whole transaction succeeds, or if the transaction fails on any of the individual operations, even if those operations are never committed and do not appear in the data after the transaction has been rolled back.

    So answering your question, you would be billed for 500 deletes, regardless of whether the transaction succeeds or is rolled back.