Azure SQL Database has no server-side statement timeout configuration across client drivers
0 reputation · 04 Jan 2023, 21:46 UTC
0 reputation · 04 Jan 2023, 21:46 UTC
Azure SQL Database does not expose a native T-SQL SET STATEMENT_TIMEOUT, relying instead on client driver CommandTimeout settings for query duration limits. This design creates a fragmentation point where timeout thresholds, error handling, and cancellation semantics differ across ADO.NET, JDBC, ODBC, Python, and PHP drivers.
A related concern is that per-session LOCK_TIMEOUT values are not retained when connections are drawn from a pool or re-established after reconnection, potentially allowing lock-wait periods to exceed intended bounds.
Additionally, client-initiated cancellation via KILL or driver-level cancel may terminate a statement without rolling back an active transaction, leaving the session in an inconsistent state if application-level try/catch and transaction management are absent.
Given these gaps, what mechanisms can applications adopt to enforce uniform statement timeout behavior across heterogeneous drivers? How should transaction boundaries be structured to absorb cancellation side effects without data corruption? And does the Query Store instrumentation provide sufficient signal to detect timeout-driven query abandonment in production workloads?
Azure SQL Database does not provide a server-side SET STATEMENT_TIMEOUT. Timeout enforcement is client-side only, per driver CommandTimeout / query timeout setting. There is no T-SQL setting that caps statement duration for all clients.
Per-session LOCK_TIMEOUT is also session scoped. With connection pooling or reconnection, the session is new and the previous LOCK_TIMEOUT is not retained unless reapplied on checkout. Client-initiated cancellation can abort a statement without automatically rolling back an open transaction, leaving the session in an active transaction if the app does not explicitly roll back.
The fragmentation you see across ADO.NET, JDBC, ODBC, Python and PHP is expected. Each driver has a different property name and default, and pooling resets session context. Cancellation semantics are driver dependent, so a timeout in one client may surface as a different error in another.
Query Store records start_time, end_time, elapsed_time and a cancel reason. A query that stops early with cancel_reason indicating client-initiated cancellation is a signal, but Query Store alone does not prove the cause was a driver timeout versus an explicit client cancel. Supplemental telemetry is needed for reliable detection.
Assumptions: you are using pooled connections and multiple drivers in production. Uncertainty remains on exact driver property names and defaults, which vary by version. Verification steps: review each driver docs for the correct timeout property and default, enable Query Store and compare elapsed time to configured timeout, and run a controlled sleep query longer than timeout to verify consistent exception behavior across drivers.
One missing diagnostic detail that changes the recommendation: which connection pool implementation and whether you reset session context on checkout. If you are using a pool that preserves session state, the LOCK_TIMEOUT reapply step can be reduced.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.