You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: azure-sql/database/troubleshoot-common-connectivity-issues.md
+11-8Lines changed: 11 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ description: Learn how to troubleshoot, diagnose, and prevent a SQL connection e
4
4
author: WilliamDAssafMSFT
5
5
ms.author: wiassaf
6
6
ms.reviewer: sureshka, davidengel, mathoma, vanto
7
-
ms.date: 12/04/2025
7
+
ms.date: 03/24/2026
8
8
ms.service: azure-sql-database
9
9
ms.subservice: development
10
10
ms.topic: troubleshooting
@@ -46,7 +46,7 @@ After a delay of several seconds, retry the connection.
46
46
47
47
-**A transient error occurs during a query command**
48
48
49
-
Do not immediately retry the command. Instead, after a delay, freshly establish the connection. Then retry the command.
49
+
Don't immediately retry the command. Instead, after a delay, freshly establish the connection. Then retry the command.
50
50
51
51
<aid="j-retry-logic-transient-faults"></a>
52
52
@@ -59,7 +59,7 @@ Client programs that occasionally encounter a transient error are more robust wh
59
59
### Principles for retry
60
60
61
61
- If the error is transient, retry to open a connection.
62
-
-Do not directly retry a `SELECT` statement that failed with a transient error. Instead, establish a fresh connection, and then retry the `SELECT`.
62
+
-Don't directly retry a `SELECT` statement that failed with a transient error. Instead, establish a fresh connection, and then retry the `SELECT`.
63
63
- When an `UPDATE` statement fails with a transient error, establish a fresh connection before you retry the `UPDATE`. The retry logic must ensure that either the entire database transaction finished or that the entire transaction is rolled back.
64
64
65
65
### Other considerations for retry
@@ -127,7 +127,10 @@ To make this test practical, your program recognizes a runtime parameter that ca
127
127
128
128
## .NET SqlConnection parameters for connection retry
129
129
130
-
If your client program connects to your database in Azure SQL Database by using the .NET Framework class **System.Data.SqlClient.SqlConnection**, use .NET 4.6.1 or a later version (or .NET Core) so that you can use its connection retry feature. For more information about this feature, see [SqlConnection.ConnectionString Property](/dotnet/api/system.data.sqlclient.sqlconnection.connectionstring?view=netframework-4.8&preserve-view=true).
130
+
If your client program connects to your database in Azure SQL Database by using the .NET class **Microsoft.Data.SqlClient.SqlConnection** or **System.Data.SqlClient.SqlConnection**, you can use connection retry features. For `System.Data.SqlClient`, use .NET Framework 4.6.1 or a later version (or .NET Core). For more information about this feature, see [SqlConnection.ConnectionString Property](/dotnet/api/system.data.sqlclient.sqlconnection.connectionstring?view=netframework-4.8&preserve-view=true).
131
+
132
+
> [!NOTE]
133
+
> `Microsoft.Data.SqlClient` is the recommended ADO.NET data provider for new application development. In addition to connection retry, it supports [configurable retry logic](/sql/connect/ado-net/configurable-retry-logic) for both connection and command retries. For more information, see [Introduction to the Microsoft.Data.SqlClient namespace](/sql/connect/ado-net/introduction-microsoft-data-sqlclient-namespace).
131
134
132
135
<!--
133
136
2015-11-30, FwLink 393996 points to dn632678.aspx, which links to a downloadable .docx related to SqlClient and SQL Server 2014.
@@ -206,11 +209,11 @@ The **ConnectRetryCount** and **ConnectRetryInterval** parameters let your **Sql
206
209
- SqlConnection.Open method call
207
210
- SqlCommand.Execute* method calls
208
211
209
-
There is a subtlety. If a transient error occurs while your *query* is being executed, your **SqlConnection** object doesn't retry the connect operation. It certainly doesn't retry your query. However, **SqlConnection** very quickly checks the connection before sending your query for execution. If the quick check detects a connection problem, **SqlConnection** retries the connect operation. If the retry succeeds, your query is sent for execution.
212
+
There's a subtlety. If a transient error occurs while your *query* is being executed, your **SqlConnection** object doesn't retry the connect operation. It certainly doesn't retry your query. However, **SqlConnection** very quickly checks the connection before sending your query for execution. If the quick check detects a connection problem, **SqlConnection** retries the connect operation. If the retry succeeds, your query is sent for execution.
210
213
211
214
### Should ConnectRetryCount be combined with application retry logic
212
215
213
-
Suppose your application has robust custom retry logic. It might retry the connect operation four times. If you add **ConnectRetryInterval** and **ConnectRetryCount** =3 to your connection string, you will increase the retry count to 4 * 3 = 12 retries. You might not intend such a high number of retries.
216
+
Suppose your application has robust custom retry logic. It might retry the connect operation four times. If you add **ConnectRetryInterval** and **ConnectRetryCount** =3 to your connection string, you increase the retry count to 4 * 3 = 12 retries. You might not intend such a high number of retries.
214
217
215
218
<aid="a-connection-connection-string"></a>
216
219
@@ -255,7 +258,7 @@ For background information about configuration of ports and IP addresses in your
255
258
256
259
### Connection: ADO.NET 4.6.2 or later
257
260
258
-
If your program uses ADO.NET classes like **System.Data.SqlClient.SqlConnection** to connect to SQL Database, we recommend that you use .NET Framework version 4.6.2 or later.
261
+
If your program uses ADO.NET classes like **System.Data.SqlClient.SqlConnection** to connect to SQL Database, we recommend that you use .NET Framework version 4.6.2 or later. For new applications, consider using [`Microsoft.Data.SqlClient`](/sql/connect/ado-net/introduction-microsoft-data-sqlclient-namespace), which provides the same connectivity with enhanced features.
259
262
260
263
<aid="starting-with-adonet-462"></a>
261
264
@@ -270,7 +273,7 @@ If your program uses ADO.NET classes like **System.Data.SqlClient.SqlConnection*
270
273
- For SQL Database, reliability is improved when you open a connection by using the **SqlConnection.Open** method. The **Open** method now incorporates best-effort retry mechanisms in response to transient faults for certain errors within the connection timeout period.
271
274
- Connection pooling is supported, which includes an efficient verification that the connection object it gives your program is functioning.
272
275
273
-
When you use a connection object from a connection pool, we recommend that your program temporarily closes the connection when it's not immediately in use. It's not expensive to reopen a connection, but it is to create a new connection.
276
+
When you use a connection object from a connection pool, we recommend that your program temporarily closes the connection when it's not immediately in use. It's not expensive to reopen a connection, but it's to create a new connection.
274
277
275
278
If you use ADO.NET 4.0 or earlier, we recommend that you upgrade to the latest ADO.NET. As of August 2018, you can [download ADO.NET 4.6.2](https://devblogs.microsoft.com/dotnet/announcing-the-net-framework-4-7-2).
You might see errors 9002 or 40552 when the transaction log is full and cannot accept new transactions. These errors occur when the database transaction log, managed by Azure SQL Database, exceeds thresholds for space and cannot continue to accept transactions. These errors are similar to issues with a full transaction log in SQL Server, but have different resolutions in SQL Server, Azure SQL Database, and Azure SQL Managed Instance.
23
+
You might see errors 9002 or 40552 when the transaction log is full and can't accept new transactions. These errors occur when the database transaction log, managed by Azure SQL Database, exceeds thresholds for space and can't continue to accept transactions. These errors are similar to issues with a full transaction log in SQL Server, but have different resolutions in SQL Server, Azure SQL Database, and Azure SQL Managed Instance.
24
24
25
25
> [!NOTE]
26
26
> **This article is focused on Azure SQL Database.** Azure SQL Database is based on the latest stable version of the Microsoft SQL Server database engine, so much of the content is similar, though troubleshooting options and tools might differ from SQL Server.
@@ -35,7 +35,7 @@ In Azure SQL Database, transaction log backups are taken automatically. For freq
35
35
36
36
Free disk space, database file growth, and file location are also managed, so the typical causes and resolutions of transaction log issues are different from SQL Server.
37
37
38
-
Similar to SQL Server, the transaction log for each database is truncated whenever a log backup completes successfully. Truncation leaves empty space in the log file, which can then be used for new transactions. When the log file cannot be truncated by log backups, the log file grows to accommodate new transactions. If the log file grows to its maximum limit in Azure SQL Database, new write transactions fail.
38
+
Similar to SQL Server, the transaction log for each database is truncated whenever a log backup completes successfully. Truncation leaves empty space in the log file, which can then be used for new transactions. When the log file can't be truncated by log backups, the log file grows to accommodate new transactions. If the log file grows to its maximum limit in Azure SQL Database, new write transactions fail.
39
39
40
40
For information on transaction log sizes, see:
41
41
@@ -46,36 +46,36 @@ For information on transaction log sizes, see:
46
46
47
47
## Prevented transaction log truncation
48
48
49
-
To discover what is preventing log truncation in a given case, refer to `log_reuse_wait_desc` in `sys.databases`. The log reuse wait informs you to what conditions or causes are preventing the transaction log from being truncated by a regular log backup. For more information, see [sys.databases (Transact-SQL)](/sql/relational-databases/system-catalog-views/sys-databases-transact-sql?view=azuresqldb-current&preserve-view=true).
49
+
To discover what's preventing log truncation in a given case, refer to `log_reuse_wait_desc` in `sys.databases`. The log reuse wait informs you to what conditions or causes are preventing the transaction log from being truncated by a regular log backup. For more information, see [sys.databases (Transact-SQL)](/sql/relational-databases/system-catalog-views/sys-databases-transact-sql?view=azuresqldb-current&preserve-view=true).
For Azure SQL Database, it is recommended to connect to a specific user database, rather than the `master` database, to execute this query.
55
+
For Azure SQL Database, it's recommended to connect to a specific user database, rather than the `master` database, to execute this query.
56
56
57
57
The following values of `log_reuse_wait_desc` in `sys.databases` can indicate the reason why the database's transaction log truncation is being prevented:
|`NOTHING`| Typical state. There is nothing blocking the log from truncating. | No. |
61
+
|`NOTHING`| Typical state. There's nothing blocking the log from truncating. | No. |
62
62
|`CHECKPOINT`| A checkpoint is needed for log truncation. Rare. | No response required unless sustained. If sustained, file a support request with [Azure Support](https://portal.azure.com/#create/Microsoft.Support). |
63
63
|`LOG BACKUP`| A log backup is required. | No response required unless sustained. If sustained, file a support request with [Azure Support](https://portal.azure.com/#create/Microsoft.Support). |
64
64
|`ACTIVE BACKUP OR RESTORE`| A database backup is in progress. | No response required unless sustained. If sustained, file a support request with [Azure Support](https://portal.azure.com/#create/Microsoft.Support). |
65
-
|`ACTIVE TRANSACTION`| An ongoing transaction is preventing log truncation. | The log file cannot be truncated due to active and/or uncommitted transactions. See next section.|
65
+
|`ACTIVE TRANSACTION`| An ongoing transaction is preventing log truncation. | The log file can't be truncated due to active and/or uncommitted transactions. See next section.|
66
66
|`REPLICATION`| In Azure SQL Database, this might occur if [change data capture (CDC)](/sql/relational-databases/track-changes/about-change-data-capture-sql-server) is enabled. | Query [sys.dm_cdc_errors](/sql/relational-databases/system-dynamic-management-views/change-data-capture-sys-dm-cdc-errors) and resolve errors. If unresolvable, file a support request with [Azure Support](https://portal.azure.com/#create/Microsoft.Support).|
67
67
|`AVAILABILITY_REPLICA`| Synchronization to the secondary replica is in progress. | No response required unless sustained. If sustained, file a support request with [Azure Support](https://portal.azure.com/#create/Microsoft.Support). |
68
68
69
69
### Log truncation prevented by an active transaction
70
70
71
-
The most common scenario for a transaction log that cannot accept new transactions is a long-running or blocked transaction.
71
+
The most common scenario for a transaction log that can't accept new transactions is a long-running or blocked transaction.
72
72
73
73
Run this sample query to find uncommitted or active transactions and their properties.
74
74
75
75
- Returns information about transaction properties, from [sys.dm_tran_active_transactions](/sql/relational-databases/system-dynamic-management-views/sys-dm-tran-session-transactions-transact-sql?view=azuresqldb-current&preserve-view=true).
76
76
- Returns session connection information, from [sys.dm_exec_sessions](/sql/relational-databases/system-dynamic-management-views/sys-dm-exec-sessions-transact-sql?view=azuresqldb-current&preserve-view=true).
77
77
- Returns request information (for active requests), from [sys.dm_exec_requests](/sql/relational-databases/system-dynamic-management-views/sys-dm-exec-requests-transact-sql?view=azuresqldb-current&preserve-view=true). This query can also be used to identify sessions being blocked, look for the `request_blocked_by`. For more information, see [Gather blocking information](understand-resolve-blocking.md?view=azuresql-db&preserve-view=true#gather-blocking-information).
78
-
- Returns the current request's text or input buffer text, using the [sys.dm_exec_sql_text](/sql/relational-databases/system-dynamic-management-views/sys-dm-exec-sql-text-transact-sql?view=azuresqldb-current&preserve-view=true) or [sys.dm_exec_input_buffer](/sql/relational-databases/system-dynamic-management-views/sys-dm-exec-input-buffer-transact-sql?view=azuresqldb-current&preserve-view=true) DMVs. If the data returned by the `text` field of `sys.dm_exec_sql_text` is NULL, the request is not active but has an outstanding transaction. In that case, the `event_info` field of `sys.dm_exec_input_buffer` contains the last statement passed to the database engine.
78
+
- Returns the current request's text or input buffer text, using the [sys.dm_exec_sql_text](/sql/relational-databases/system-dynamic-management-views/sys-dm-exec-sql-text-transact-sql?view=azuresqldb-current&preserve-view=true) or [sys.dm_exec_input_buffer](/sql/relational-databases/system-dynamic-management-views/sys-dm-exec-input-buffer-transact-sql?view=azuresqldb-current&preserve-view=true) DMVs. If the data returned by the `text` field of `sys.dm_exec_sql_text` is NULL, the request isn't active but has an outstanding transaction. In that case, the `event_info` field of `sys.dm_exec_input_buffer` contains the last statement passed to the database engine.
79
79
80
80
```sql
81
81
SELECT [database_name] = db_name(s.database_id)
@@ -140,8 +140,8 @@ To resolve this issue, try the following methods:
140
140
141
141
1. The issue can occur in any DML operation such as insert, update, or delete. Review the transaction to avoid unnecessary writes. Try to reduce the number of rows that are operated on immediately by implementing batching or splitting into multiple smaller transactions. For more information, see [How to use batching to improve SQL Database application performance](../performance-improve-use-batching.md?view=azuresql-db&preserve-view=true).
142
142
1. The issue can occur because of index rebuild operations. To avoid this issue, ensure the following formula is true: (number of rows that are affected in the table) multiplied by (the average size of field that's updated in bytes + 80) < 2 gigabytes (GB). For large tables, consider creating partitions and performing index maintenance only on some partitions of the table. For more information, see [Create Partitioned Tables and Indexes](/sql/relational-databases/partitions/create-partitioned-tables-and-indexes?view=azuresqldb-current&preserve-view=true).
143
-
1. If you perform bulk inserts using the `bcp.exe` utility or the `System.Data.SqlClient.SqlBulkCopy` class, try using the `-b batchsize` or `BatchSize` options to limit the number of rows copied to the server in each transaction. For more information, see [bcp Utility](/sql/tools/bcp-utility).
144
-
1. If you are rebuilding an index with the `ALTER INDEX` statement, use the `SORT_IN_TEMPDB = ON`, `ONLINE = ON`, and `RESUMABLE=ON` options. With resumable indexes, log truncation is more frequent. For more information, see [ALTER INDEX (Transact-SQL)](/sql/t-sql/statements/alter-index-transact-sql?view=azuresqldb-current&preserve-view=true).
143
+
1. If you perform bulk inserts using the `bcp.exe` utility or the `SqlBulkCopy` class (available in both `Microsoft.Data.SqlClient` and `System.Data.SqlClient`), try using the `-b batchsize` or `BatchSize` options to limit the number of rows copied to the server in each transaction. For more information, see [bcp Utility](/sql/tools/bcp-utility).
144
+
1. If you're rebuilding an index with the `ALTER INDEX` statement, use the `SORT_IN_TEMPDB = ON`, `ONLINE = ON`, and `RESUMABLE=ON` options. With resumable indexes, log truncation is more frequent. For more information, see [ALTER INDEX (Transact-SQL)](/sql/t-sql/statements/alter-index-transact-sql?view=azuresqldb-current&preserve-view=true).
145
145
146
146
> [!NOTE]
147
147
> For more information on other resource governance errors, see [Resource governance errors](troubleshoot-common-errors-issues.md?view=azuresql-db&preserve-view=true#resource-governance-errors).
0 commit comments