Azure SQL Database 2022: Query Timeout Enforcement Across Multi-Statement Batches and Distributed Transactions
0 reputation · 01 Jan 2020, 07:04 UTC
Scope
Understanding how client-configured query timeouts and explicit cancellation calls propagate through Azure SQL Database when a workload spans multiple statements in a single batch or participates in a distributed transaction.
Constraints and Uncertainty
Documentation indicates that a client-side timeout (for example, CommandTimeout or setQueryTimeout) is enforced per statement, yet the behavior for the surrounding transaction is not guaranteed. Error codes such as 40613 and 60001 may surface after partial row processing, leaving the transaction in an ambiguous committed or uncommitted state. Driver version differences further complicate whether the timeout reaches the server at all. In geo-replicated or high-availability configurations, a cancelled query can continue executing on secondary replicas until the primary acknowledges the cancellation, delaying cleanup.
Open Questions
- Does a client-set timeout abort the entire multi-statement batch, or only the statement that exceeds the limit?
- When
SqlCommand.Cancel()is invoked inside a distributed transaction, what determines whether the transaction rolls back automatically versus remaining open? - Are there documented version boundaries (driver or server) where the timeout propagation behavior changes?