Maaz Bin Khawar
Maaz Bin Khawar

Reputation: 460

Do firestore batch writes get re-run automatically on failure?

While going through the official documentation I found out that transactions are automatically re-run a finite number of times by the SDK on failure, however in case of Batch Writes it is not explicitly mentioned.

The documentation does mention that batch writes are atomic just like transactions but that does not necessarily implies that they get re-run also on failure.

Upvotes: 5

Views: 1754

Answers (1)

Doug Stevenson
Doug Stevenson

Reputation: 317372

Batch writes are not retried if there is a failure. The entire thing is just rolled back, and you have to figure out for yourself if you want to retry.

Transactions are retried because they are explicitly trying to make a change based on the contents of existing document. Since those documents could change between the round trip between the client and server, the retry is necessary to automatically handle that case, if it happens. Batch writes don't have this problem, since they are atomic, but not really transactional in nature.

Upvotes: 8

Related Questions