DistributedReadTransaction SHALL support ReadItem operations. Each operation SHALL independently specify its target database, container, partition key, and document id, allowing reads from any combination of partitions and containers within the same database account.
- WHEN a
DistributedReadTransactionis built with ReadItem operations targeting different partition keys within the same container - THEN
CommitTransactionAsyncSHALL return all items as a consistent snapshot
- WHEN a
DistributedReadTransactionis built with ReadItem operations targeting different containers within the same database account - THEN
CommitTransactionAsyncSHALL return all items as a consistent snapshot
The response SHALL expose an ETag for each successfully read item, reflecting the document version that was read.
- WHEN
CommitTransactionAsynccompletes withIsSuccessStatusCode = true - THEN each operation's result SHALL carry a non-null
ETagthat can be used asIfMatchEtagon a subsequentDistributedWriteTransactionfor conditional writes (optimistic CAS pattern)
Each ReadItem operation in a DistributedReadTransaction SHALL support an optional IfNoneMatchETag precondition. If the document's current ETag matches, the server SHALL return 304 Not Modified for that operation with no response body.
- WHEN
CommitTransactionAsyncis called and one operation specifies anIfNoneMatchETagthat matches the document's current ETag - THEN that operation's result SHALL carry
StatusCode = 304and a null resource body
- WHEN
CommitTransactionAsyncis called and one operation specifies anIfNoneMatchETagthat does not match the document's current ETag - THEN that operation's result SHALL carry
StatusCode = 200and the full document body
DistributedReadTransaction SHALL execute all staged ReadItem operations against a single consistent server-side snapshot, guaranteeing that no two results reflect different logical instants (no read skew).
- WHEN
CommitTransactionAsyncis called with multiple ReadItem operations targeting different partitions or containers - THEN the service SHALL return all items as they existed at the same logical point in time
- AND the SDK SHALL return a
DistributedTransactionResponsewithIsSuccessStatusCode = trueandStatusCode = 200
- WHEN
CommitTransactionAsyncis called and one of the staged items does not exist in the container - THEN the SDK SHALL return a
DistributedTransactionResponsewithStatusCode = 207 - AND the missing item's result SHALL carry
StatusCode = 404 - AND all other items' results SHALL carry their actual response status codes
After execution completes, the SDK SHALL merge per-operation session tokens from the response into the client's ISessionContainer.
- WHEN
CommitTransactionAsynccompletes and the response contains per-operationsessionTokenvalues - THEN the SDK SHALL merge each response token into
ISessionContainerfor the corresponding partition
The SDK SHALL route every CommitTransactionAsync request through the Gateway or Thin Client endpoint. Direct mode is not supported for distributed transactions.
- WHEN the
CosmosClientis configured with Direct connectivity mode - THEN the SDK SHALL override connectivity to Gateway mode and route
CommitTransactionAsyncto the Gateway read-transaction endpoint
CommitTransactionAsync SHALL be safe to retry on any transient failure without risk of duplicate side effects. No idempotency token is required.
- WHEN
CommitTransactionAsyncexperiences a transient failure (408 Request Timeout or 503 Service Unavailable) - THEN the SDK SHALL automatically retry the request
CommitTransactionAsync SHALL throw NotSupportedException if the account is configured with multiple write regions.
- WHEN the Cosmos DB account has
UseMultipleWriteLocations = true - THEN
CommitTransactionAsyncSHALL throwNotSupportedExceptionbefore sending any request
The ConsistencyLevel set in DistributedReadTransactionRequestOptions SHALL determine how fresh the server-side snapshot is.
- WHEN
CommitTransactionAsyncis called withConsistencyLevel = Strong - THEN the service SHALL return all items from the globally latest committed version with no stale reads
- WHEN
CommitTransactionAsyncis called withConsistencyLevel = Sessionand per-operation session tokens are populated from the client'sISessionContainer - THEN the service SHALL return items that are at least as fresh as the provided session token for each partition
The SDK SHALL reject a CommitTransactionAsync call before dispatch if the staged operations exceed the supported limit.
- WHEN more than 100 ReadItem operations have been staged on the transaction
- THEN
CommitTransactionAsyncSHALL throwArgumentExceptionbefore sending any request
When the Gateway returns 429 (Too Many Requests), the SDK SHALL automatically retry after the x-ms-retry-after-ms interval.
- WHEN
CommitTransactionAsyncreceives a 429 response - THEN the SDK SHALL wait for
x-ms-retry-after-msand retry the request
The SDK SHALL emit an OpenTelemetry span for each CommitTransactionAsync call.
- WHEN
CommitTransactionAsynccompletes successfully - THEN the SDK SHALL emit a span with operation name
commit_distributed_read_transaction,db.cosmosdb.status_code = 200, anddb.cosmosdb.request_chargeset to the total RU charge for all read operations