Managing Distributed Deadlocks in Multi-Document TransactionalBatches
Updated Apr 28, 2026
Short answer
TransactionalBatch provides ACID atomicity within a logical partition. Deadlocks are avoided by the internal sequential execution and optimistic locking on the replica set.
Deep explanation
While Cosmos DB is a distributed database, TransactionalBatch operations are scoped to a single logical partition. This means the transactions are handled by the same replica set (Paxos leader). The system uses optimistic concurrency control (OCC). Instead of traditional pessimistic locks (which cause deadlocks), Cosmos DB validates the version (ETag) at commit time. If two batches conflict, the latter fails with a 412 Precondition Failed, forcing the client to retry.
Unlock with a Pro subscription to view this section.
View pricingReal-world example
No real-world example available yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProCommon mistakes
No common mistakes listed yet.
Unlock with a Pro subscription to view this section.
Upgrade to ProFollow-up questions
No follow-up questions available yet.
Unlock with a Pro subscription to view this section.
Upgrade to Pro