Training
Module
Perform cross-document transactional operations with the Azure Cosmos DB for NoSQL - Training
Perform operations on multiple items in single logical units of work.
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
A transaction is a sequence of operations performed as a single logical unit of work. It exhibits the common ACID (atomicity, consistency, isolation, durability) properties of database transactions:
Isolation level defines the degree to which the transaction must be isolated from modifications made by other transactions. There are two isolation levels that are supported in Reliable Collections:
Reliable Collections automatically choose the isolation level to use for a given read operation depending on the operation and the role of the replica at the time of transaction's creation. Following is the table that depicts isolation level defaults for Reliable Dictionary and Queue operations.
Operation \ Role | Primary | Secondary |
---|---|---|
Single Entity Read | Repeatable Read | Snapshot |
Enumeration, Count | Snapshot | Snapshot |
Note
Common examples for Single Entity Operations are IReliableDictionary.TryGetValueAsync
, IReliableQueue.TryPeekAsync
.
Both the Reliable Dictionary and the Reliable Queue support Read Your Writes. In other words, any write within a transaction will be visible to a following read that belongs to the same transaction.
In Reliable Collections, all transactions implement rigorous two phase locking: a transaction does not release the locks it has acquired until the transaction terminates with either an abort or a commit.
Reliable Dictionary uses row-level locking for all single entity operations.
Reliable Queue trades off concurrency for strict transactional FIFO property.
Reliable Queue uses operation-level locks allowing one transaction with TryPeekAsync
and/or TryDequeueAsync
and one transaction with EnqueueAsync
at a time.
Note that to preserve FIFO, if a TryPeekAsync
or TryDequeueAsync
ever observes that the Reliable Queue is empty, they will also lock EnqueueAsync
.
Write operations always take Exclusive locks. For read operations, the locking depends on a couple of factors:
The lock compatibility matrix can be found in the following table:
Request \ Granted | None | Shared | Update | Exclusive |
---|---|---|---|---|
Shared | No conflict | No conflict | Conflict | Conflict |
Update | No conflict | No conflict | Conflict | Conflict |
Exclusive | No conflict | Conflict | Conflict | Conflict |
The timeout argument in Reliable Collections APIs is used for deadlock detection. For example, two transactions (T1 and T2) are trying to read and update K1. It is possible for them to deadlock, because they both end up having the Shared lock. In this case, one or both of the operations will time out. In this scenario, an Update lock could prevent such a deadlock.
Training
Module
Perform cross-document transactional operations with the Azure Cosmos DB for NoSQL - Training
Perform operations on multiple items in single logical units of work.
Documentation
Guidelines for Reliable Collections - Azure Service Fabric
Guidelines and Recommendations for using Service Fabric Reliable Collections in an Azure Service Fabric application.
Working with Reliable Collections - Azure Service Fabric
Learn the best practices for working with Reliable Collections within an Azure Service Fabric application.
Introduction to Reliable Collections - Azure Service Fabric
Service Fabric stateful services provide reliable collections that enable you to write highly available, scalable, and low-latency cloud applications.