azure-docs
azure-docs copied to clipboard
Doc mistake? - .NET SqlConnection parameters for connection retry
Hi team, can you check and confirm if this is a mistake in the documentation?
.NET SqlConnection parameters for connection retry
"For example, if the count equals 3 and the interval equals 10 seconds, a timeout of only 29 seconds doesn't give the system enough time for its third and final retry to connect: 29 < 3 * 10."
Firstly, 3 * 10 = 30, so it doesn't make sense that "doesn't give the system enough time for its third and final retry to connect" when 29<30.
Secondly, according to the quote below, the first retry to connect happens immediately, so if the retry count equals 3, shouldn't the calculation be, (3-1) * 10? Which is 20 seconds, therefore there is not enough time for the final retry to connect to work?
https://docs.microsoft.com/en-us/dotnet/api/system.data.sqlclient.sqlconnection.connectionstring?view=dotnet-plat-ext-6.0
ConnectRetryInterval | 10 | Specifies the time between each connection retry attempt (ConnectRetryCount). Valid values are 1 to 60 seconds (default=10), applied after the first reconnection attempt. When a broken connection is detected, the client immediately attempts to reconnect; this is the first reconnection attempt and only occurs if ConnectRetryCount is greater than 0. If the first reconnection attempt fails and ConnectRetryCount is greater than 1, the client waits ConnectRetryInterval to try the second and subsequent reconnection attempts.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 8d7562b8-cb8a-4664-8c80-ef81610e5995
- Version Independent ID: 43446cd9-a3f0-35e9-f7d7-8a2990ba5331
- Content: Working with transient errors - Azure SQL Database
- Content Source: azure-sql/database/troubleshoot-common-connectivity-issues.md
- Service: sql-database
- Sub-service: development
- GitHub Login: @ramakoni1
- Microsoft Alias: ramakoni
Hi @helenxfu, thanks for bringing this to our attention. I have assigned the issue to the content author to evaluate and confirm if this is a mistake
hi @helenxfu -Thank you for raising this issue. Am investigating this further and will submit a PR to docs later this week or early next week with clarification.
hi @helenxfu - Sorry for the delay in updating. We will be updating the docs with the following clarifications.
The connection retry settings (ConnectRetryCount and ConnectRetryInterval) apply to connection resiliency. Connection resiliency encompasses two distinct scenarios.
-
Open connection resiliency refers to the initial SqlConnection.Open() event. The first connection attempt would be counted as try zero. ConnectRetryCount applies to retry numbers above that. So, when connection zero fails (might not be immediate), ConnectRetryInterval is applied first followed by subsequent ConnectRetryCount (and ConnectRetryInterval) attempts.
-
Idle connection resiliency refers to automatic detection and reconnection of existing, idle connections that have been broken. The first attempt at reconnecting a broken idle connection count as the first retry attempt.
See examples below:
Scenario: New connection
ConnectRetryCount -3, ConnectRetryInterval - 10 seconds
4:10:00 - Connection.Open() - zero attempt
4:10:01 - Connection failure detected
4:10:11 - Retry 1 --> First retry happens after ConnectRetryInterval
4:10:21 - Retry 2
4:10:31 - Retry 3
Scenario: Idle connection ConnectRetryCount -3, ConnectRetryInterval - 10 seconds
4:10:00 - Detect broken connection - zero attempt 4:10:01 - Retry 1 -->First retry happens immediately 4:10:11 - Retry 2 4:10:21 - Retry 3
Note: The above times are just for demonstration purposes and the detection times in both scenarios depend on underlying infrastructure.
@helenxfu - docs are now updated. Please check updated section: https://learn.microsoft.com/en-us/azure/azure-sql/database/troubleshoot-common-connectivity-issues?view=azuresql#net-sqlconnection-parameters-for-connection-retry - thanks again for reporting this. Please let us know if anything else needs clarification.
Hi @helenxfu , thanks so much for helping improve our content! Since your issue was addressed, we'll go ahead and close out this Git Issue but please feel free to comment should you need anything further.
Thanks again and hope you have a wonderful rest of your day! Masha from the SQL Docs team #please-close