Skip to content
Merged
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<docs>
<docs>
<members name="SqlConfigurableRetryFactory">
<SqlConfigurableRetryFactory>
<summary>
Expand Down Expand Up @@ -113,6 +113,42 @@
A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.) (Microsoft SQL Server, Error: 233)
</description>
</item>
<item>
<term>64</term>
<description>
A connection was successfully established with the server, but then an error occurred during the login process. (provider: TCP Provider, error: 0 - The specified network name is no longer available.) (Microsoft SQL Server, Error: 64)
</description>
</item>
<item>
<term>20</term>
<description>The instance of SQL Server you attempted to connect to does not support encryption.</description>
</item>
<item>
<term>0</term>
<description>A connection was successfully established with the server, but then an error occurred during the pre-login handshake.</description>
</item>
<item>
<term>-2</term>
<description>Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.</description>
</item>
<item>
<term>207</term>
<description>Invalid column name.</description>
</item>
<item>
<term>18456</term>
<description>
Login failed for user. (Using managed identity in Azure Sql Server throws 18456 for non-existent database instead of 4060.)
</description>
</item>
<item>
<term>42108</term>
<description>Can not connect to the SQL pool since it is paused. Please resume the SQL pool and try again.</description>
Comment thread
MatthiasHuygelen marked this conversation as resolved.
Outdated
</item>
<item>
<term>42109</term>
<description>The SQL pool is warming up. Please try again.</description>
</item>
Comment thread
MatthiasHuygelen marked this conversation as resolved.
</list>
</remarks>
</SqlConfigurableRetryFactory>
Expand Down Expand Up @@ -250,5 +286,10 @@
</format>
</remarks>
</CreateNoneRetryProvider>
<DefaultTransientErrors>
<summary>
Gets a readonly replica of the inner transient error list.
</summary>
</DefaultTransientErrors>
</members>
</docs>
Original file line number Diff line number Diff line change
Expand Up @@ -1971,6 +1971,8 @@ public sealed class SqlRetryLogicOption
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConfigurableRetryFactory.xml' path='docs/members[@name="SqlConfigurableRetryFactory"]/SqlConfigurableRetryFactory/*' />
public sealed class SqlConfigurableRetryFactory
{
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConfigurableRetryFactory.xml' path='docs/members[@name="SqlConfigurableRetryFactory"]/DefaultTransientErrors/*' />
public static System.Collections.ObjectModel.ReadOnlyCollection<int> DefaultTransientErrors { get { throw null; } }
Comment thread
MatthiasHuygelen marked this conversation as resolved.
Outdated
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConfigurableRetryFactory.xml' path='docs/members[@name="SqlConfigurableRetryFactory"]/CreateExponentialRetryProvider/*' />
public static SqlRetryLogicBaseProvider CreateExponentialRetryProvider(SqlRetryLogicOption retryLogicOption) { throw null; }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConfigurableRetryFactory.xml' path='docs/members[@name="SqlConfigurableRetryFactory"]/CreateIncrementalRetryProvider/*' />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1954,6 +1954,8 @@ public sealed class SqlRetryLogicOption
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConfigurableRetryFactory.xml' path='docs/members[@name="SqlConfigurableRetryFactory"]/SqlConfigurableRetryFactory/*' />
public sealed class SqlConfigurableRetryFactory
{
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConfigurableRetryFactory.xml' path='docs/members[@name="SqlConfigurableRetryFactory"]/DefaultTransientErrors/*' />
public static System.Collections.ObjectModel.ReadOnlyCollection<int> DefaultTransientErrors { get { throw null; } }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConfigurableRetryFactory.xml' path='docs/members[@name="SqlConfigurableRetryFactory"]/CreateExponentialRetryProvider/*' />
public static SqlRetryLogicBaseProvider CreateExponentialRetryProvider(SqlRetryLogicOption retryLogicOption) { throw null; }
/// <include file='../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConfigurableRetryFactory.xml' path='docs/members[@name="SqlConfigurableRetryFactory"]/CreateIncrementalRetryProvider/*' />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;

namespace Microsoft.Data.SqlClient
Expand Down Expand Up @@ -59,8 +60,19 @@ private static readonly HashSet<int> s_defaultTransientErrors
10928, // Resource ID: %d. The %s limit for the database is %d and has been reached. For more information, see http://go.microsoft.com/fwlink/?LinkId=267637.
10060, // An error has occurred while establishing a connection to the server. When connecting to SQL Server, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.) (Microsoft SQL Server, Error: 10060)
997, // A connection was successfully established with the server, but then an error occurred during the login process. (provider: Named Pipes Provider, error: 0 - Overlapped I/O operation is in progress)
233 // A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.) (Microsoft SQL Server, Error: 233)
};
233, // A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.) (Microsoft SQL Server, Error: 233)
Comment thread
paulmedynski marked this conversation as resolved.
Outdated
64, // A connection was successfully established with the server, but then an error occurred during the login process. (provider: TCP Provider, error: 0 - The specified network name is no longer available.)
20, // The instance of SQL Server you attempted to connect to does not support encryption.
Comment thread
paulmedynski marked this conversation as resolved.
Outdated
0, // A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)
-2, // Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
207, // invalid column name
Comment thread
MatthiasHuygelen marked this conversation as resolved.
Outdated
18456 // Using managed identity in Azure Sql Server throws 18456 for non-existent database instead of 4060.
};

private static readonly ReadOnlyCollection<int> s_defaultTransientErrorsReadOnly = new([.. s_defaultTransientErrors]);
Comment thread
MatthiasHuygelen marked this conversation as resolved.
Outdated

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConfigurableRetryFactory.xml' path='docs/members[@name="SqlConfigurableRetryFactory"]/DefaultTransientErrors/*' />
public static ReadOnlyCollection<int> DefaultTransientErrors => s_defaultTransientErrorsReadOnly;

/// <include file='../../../../../../../doc/snippets/Microsoft.Data.SqlClient/SqlConfigurableRetryFactory.xml' path='docs/members[@name="SqlConfigurableRetryFactory"]/CreateExponentialRetryProvider/*' />
public static SqlRetryLogicBaseProvider CreateExponentialRetryProvider(SqlRetryLogicOption retryLogicOption)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
Comment thread
MatthiasHuygelen marked this conversation as resolved.
Outdated
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
Expand All @@ -13,37 +14,6 @@ namespace Microsoft.Data.SqlClient.ManualTesting.Tests
{
public class RetryLogicTestHelper
{
private static readonly HashSet<int> s_defaultTransientErrors
= new HashSet<int>
{
1204, // The instance of the SQL Server Database Engine cannot obtain a LOCK resource at this time. Rerun your statement when there are fewer active users. Ask the database administrator to check the lock and memory configuration for this instance, or to check for long-running transactions.
1205, // Transaction (Process ID) was deadlocked on resources with another process and has been chosen as the deadlock victim. Rerun the transaction
1222, // Lock request time out period exceeded.
49918, // Cannot process request. Not enough resources to process request.
49919, // Cannot process create or update request. Too many create or update operations in progress for subscription "%ld".
49920, // Cannot process request. Too many operations in progress for subscription "%ld".
4060, // Cannot open database "%.*ls" requested by the login. The login failed.
4221, // Login to read-secondary failed due to long wait on 'HADR_DATABASE_WAIT_FOR_TRANSITION_TO_VERSIONING'. The replica is not available for login because row versions are missing for transactions that were in-flight when the replica was recycled. The issue can be resolved by rolling back or committing the active transactions on the primary replica. Occurrences of this condition can be minimized by avoiding long write transactions on the primary.
42108, // Can not connect to the SQL pool since it is paused. Please resume the SQL pool and try again.
42109, // The SQL pool is warming up. Please try again.
40143, // The service has encountered an error processing your request. Please try again.
40613, // Database '%.*ls' on server '%.*ls' is not currently available. Please retry the connection later. If the problem persists, contact customer support, and provide them the session tracing ID of '%.*ls'.
40501, // The service is currently busy. Retry the request after 10 seconds. Incident ID: %ls. Code: %d.
40540, // The service has encountered an error processing your request. Please try again.
40197, // The service has encountered an error processing your request. Please try again. Error code %d.
10929, // Resource ID: %d. The %s minimum guarantee is %d, maximum limit is %d and the current usage for the database is %d. However, the server is currently too busy to support requests greater than %d for this database. For more information, see http://go.microsoft.com/fwlink/?LinkId=267637. Otherwise, please try again later.
10928, // Resource ID: %d. The %s limit for the database is %d and has been reached. For more information, see http://go.microsoft.com/fwlink/?LinkId=267637.
10060, // An error has occurred while establishing a connection to the server. When connecting to SQL Server, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.) (Microsoft SQL Server, Error: 10060)
997, // A connection was successfully established with the server, but then an error occurred during the login process. (provider: Named Pipes Provider, error: 0 - Overlapped I/O operation is in progress)
233, // A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - No process is on the other end of the pipe.) (Microsoft SQL Server, Error: 233)
64,
20,
0,
-2, // Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
207, // invalid column name
18456 // Using managed identity in Azure Sql Server throws 18456 for non-existent database instead of 4060.
};

public static readonly Regex FilterDmlStatements = new Regex(
@"\b(INSERT( +INTO)|UPDATE|DELETE|TRUNCATE)\b",
RegexOptions.Compiled | RegexOptions.IgnoreCase);
Expand All @@ -63,7 +33,7 @@ public static TheoryData<string, SqlRetryLogicBaseProvider> GetConnectionStringA
NumberOfTries = numberOfRetries,
DeltaTime = deltaTime ?? TimeSpan.FromMilliseconds(10),
MaxTimeInterval = maxInterval,
TransientErrors = transientErrorCodes ?? s_defaultTransientErrors,
TransientErrors = transientErrorCodes ?? SqlConfigurableRetryFactory.DefaultTransientErrors,
AuthorizedSqlCondition = RetryPreCondition(unauthorizedStatementRegex)
};

Expand Down Expand Up @@ -111,7 +81,7 @@ private static IEnumerable<SqlRetryLogicBaseProvider> GetRetryStrategiesTyped(Sq

public static IEnumerable<int> GetDefaultTransientErrorCodes(params int[] additionalCodes)
{
var transientErrorCodes = new HashSet<int>(s_defaultTransientErrors);
var transientErrorCodes = new HashSet<int>(SqlConfigurableRetryFactory.DefaultTransientErrors);
foreach (int additionalCode in additionalCodes)
{
transientErrorCodes.Add(additionalCode);
Expand Down
Loading