Does enabling HA change lock timeouts to TransientTransactionError?

Alex Chetcuti 0 Reputation points
2026-08-12T14:33:40.53+00:00

We're using Azure DocumentDB (free tier, nodeCount: 1, enableHa: false) with the MongoDB driver in C#. Under concurrent multi document transactions targeting the same document, we consistently get: MongoCommandException: Command update failed: canceling statement due to lock timeout. This error has no TransientTransactionError label, so session.WithTransactionAsync() does not retry it and bubbles as a 500 to the client.

We replicated the same workload against a local MongoDB replica set (Docker) and the same concurrent writes return TransientTransactionError instead, which WithTransactionAsync() retries automatically, resulting in zero failures.

Does enabling High Availability (enableHa: true) on an Azure DocumentDB cluster change the write conflict behavior from lock timeouts to TransientTransactionError? Or is HA purely for failover availability with no effect on how write conflicts are surfaced to the driver?

We want to understand whether upgrading to a paid tier with HA is the right path to making WithTransactionAsync() retry logic work correctly, or whether Azure DocumentDB's will always surface write conflicts as lock timeouts regardless of HA configuration.

Azure DocumentDB
Azure DocumentDB

A scalable, fully managed NoSQL database for JSON documents with fast queries and automatic indexing

0 comments No comments

2 answers

Sort by: Most helpful
  1. Andrew Taylor - COREZENN 1,385 Reputation points Volunteer Moderator
    2026-09-06T23:33:58.2533333+00:00

    Hi @Alex Chetcuti

    Thank you for reaching out to Microsoft Q&A. Based on the published documentation, I would not enable HA. Azure DocumentDB documents HA as synchronous standby replication and automatic shard failover, not as a setting that changes transaction write-conflict handling or MongoDB driver error labels. High availability in Azure DocumentDB

    I would enable HA for its availability and failover benefits, not to address this retry behavior. The Azure DocumentDB error reference does not document this lock-timeout message or a TransientTransactionError labeling contract, so I would open an Azure support request before changing tiers or adding a custom retry classification. Include a minimal reproduction, region, service and driver versions, HA settings, and the complete command response so support can confirm whether this is intended behavior, a compatibility gap, or a service issue. Troubleshoot common issues in Azure DocumentDB

    Please 'Upvote' (Thumbs-up) and 'Accept' as an answer if the response was helpful. This will help other community members facing the same issue.

    Best regards, Andrew S Taylor

    Was this answer helpful?

    0 comments No comments

  2. Ganesh Chelluri 190 Reputation points Microsoft External Staff Moderator
    2026-08-13T10:15:11.1766667+00:00

    Hi @Alex Chetcuti ,

     High Availability in Azure DocumentDB is documented as an availability and failover feature. It maintains standby replicas of shards and can redirect connections to a standby shard if a primary shard becomes unresponsive. I do not see documentation stating that enabling HA changes transaction write-conflict or lock-timeout errors into MongoDB driver errors labeled TransientTransactionError.

     Based on that, I would not treat upgrading to a paid tier with HA as the fix for WithTransactionAsync retry behavior. HA is useful for availability/failover resilience, but it is not documented as changing application-level transaction retry labels.

     For this workload, please handle this lock-timeout path with explicit application retry logic and reduce concurrent transactions that update the same document/key where possible. The current error is not being surfaced with the TransientTransactionError label, so the driver’s automatic retry path may not run for this specific failure.

     If you can share a minimal repro, the MongoDB C# driver version, and the full exception text including labels/error code with secrets removed, we can validate whether the observed error label behavior matches the current Azure DocumentDB implementation.

     Verification:

    • Re-run the same concurrent transaction workload after adding explicit retry for the lock-timeout error path.
    • Confirm whether failures reduce or disappear.
    • Confirm whether the exception still arrives without the TransientTransactionError label.

     

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.