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
The default retry method when the safety switch is enabled is the `Microsoft.Data.SqlClient.SqlConnection.SqlConfigurableRetryFactory.CreateNoneRetryProvider` for both <xref:Microsoft.Data.SqlClient.SqlConnection> and <xref:Microsoft.Data.SqlClient.SqlCommand>. You can specify a different retry method by using a configuration file.
19
+
The default retry method when the safety switch is enabled is the <xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateNoneRetryProvider%2A?displayProperty=nameWithType> for both <xref:Microsoft.Data.SqlClient.SqlConnection> and <xref:Microsoft.Data.SqlClient.SqlCommand>. You can specify a different retry method by using a configuration file.
20
20
21
21
## Configuration sections
22
22
@@ -36,7 +36,7 @@ Default retry logic options for an application can be changed by adding the foll
- `AppContextSwitchOverrides`: .NETFrameworksupportsAppContextswitchesviaan`AppContextSwitchOverrides`section, whichdoesn't need to be defined explicitly. To turn on a switch in .NET Core, you must specify this section.
39
+
- `AppContextSwitchOverrides`: .NETFrameworksupportsAppContextswitchesviaan[AppContextSwitchOverrides](/dotnet/framework/configure-apps/file-schema/runtime/appcontextswitchoverrides-element)section, whichdoesn't need to be defined explicitly. To turn on a switch in **.NET Core**, you must specify this section.
40
40
41
41
```csharp
42
42
<sectionname="AppContextSwitchOverrides"
@@ -66,19 +66,19 @@ You can enable the safety switch through a configuration file. To learn how to e
66
66
67
67
### Connection section
68
68
69
-
The following attributes can be used to specify the default retry logic for all `Microsoft.Data.SqlClient.SqlConnection` instances in an application:
69
+
The following attributes can be used to specify the default retry logic for all <xref:Microsoft.Data.SqlClient.SqlConnection> instances in an application:
70
70
71
71
- **numberOfTries**: sets the number of times to try.
72
72
73
-
- **deltaTime**: sets the gap time interval as a `System.TimeSpan` object.
73
+
- **deltaTime**: sets the gap time interval as a <xref:System.TimeSpan> object.
74
74
75
-
- **minTime**: sets the allowed minimum gap time interval as a `System.TimeSpan` object.
75
+
- **minTime**: sets the allowed minimum gap time interval as a <xref:System.TimeSpan> object.
76
76
77
-
- **maxTime**: sets the allowed maximum gap time interval as a `System.TimeSpan` object.
77
+
- **maxTime**: sets the allowed maximum gap time interval as a <xref:System.TimeSpan> object.
78
78
79
79
- **transientErrors**: sets the list of transient error numbers on which to retry.
80
80
81
-
- **retryMethod**: specifies a retry method creator that receives the retry configuration via a `Microsoft.Data.SqlClient.SqlRetryLogicOption` parameter and returns a `Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider` object.
81
+
- **retryMethod**: specifies a retry method creator that receives the retry configuration via a <xref:Microsoft.Data.SqlClient.SqlRetryLogicOption> parameter and returns a <xref:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider> object.
82
82
83
83
- **retryLogicType**: sets a custom retry logic provider, which contains the retry method creators that provide the `retryMethod`. These methods should meet the criteria for `retryMethod`. The fully qualified type name of the provider should be used. For more information, see [Specifying fully qualified type names](/dotnet/framework/reflection-and-codedom/specifying-fully-qualified-type-names).
84
84
@@ -89,35 +89,35 @@ The following attributes can be used to specify the default retry logic for all
89
89
90
90
The following attribute can also be set for all <xref:Microsoft.Data.SqlClient.SqlCommand> instances in an application:
91
91
92
-
- **authorizedSqlCondition**: Sets a pre-retry regular expression for <xref:Microsoft.Data.SqlClient.SqlCommand.CommandText> to filter specific SQL statements.
92
+
- **authorizedSqlCondition**: Sets a pre-retry regular expression for <xref:Microsoft.Data.SqlClient.SqlCommand.CommandText%2A?displayProperty=nameWithType> to filter specific SQL statements.
93
93
94
94
> [!NOTE]
95
95
> The regular expression is case sensitive.
96
96
97
97
### Examples
98
98
99
-
- Attempts to establish a connection up to three times with an approximate 1-second delay between tries by using the `Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateFixedRetryProvider` method and the default transient error list:
99
+
- Attempts to establish a connection up to three times with an approximate 1-second delay between tries by using the <xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateFixedRetryProvider%2A?displayProperty=nameWithType> method and the default transient error list:
- Attempts to establish a connection up to five times with up to a 45-second delay between tries by using the `Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateExponentialRetryProvider` method and the default transient error list:
106
+
- Attempts to establish a connection up to five times with up to a 45-second delay between tries by using the <xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateExponentialRetryProvider%2A?displayProperty=nameWithType> method and the default transient error list:
- Attempts to execute a command up to four times with a delay between 2 and 30 seconds by using the `Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateIncrementalRetryProvider` method and the default transient error list:
113
+
- Attempts to execute a command up to four times with a delay between 2 and 30 seconds by using the <xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateIncrementalRetryProvider%2A?displayProperty=nameWithType> method and the default transient error list:
- Attempts to execute a command up to eight times with a delay from one second to one minute. It's limited to commands with `CommandText` containing the word `SELECT` and exception numbers 102 or 997. It uses the built-in `Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateIncrementalRetryProvider` method:
120
+
- Attempts to execute a command up to eight times with a delay from one second to one minute. It's limited to commands with `CommandText` containing the word `SELECT` and exception numbers 102 or 997. It uses the built-in <xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateIncrementalRetryProvider%2A?displayProperty=nameWithType> method:
@@ -151,7 +151,7 @@ The following attribute can also be set for all <xref:Microsoft.Data.SqlClient.S
151
151
> Retry logic providers will be cached at the first use on a connection or command for future use during an application's lifetime.
152
152
153
153
> [!NOTE]
154
-
> Any errors when reading an application configuration file for retry logic settings won't cause errors in the application. The default `Microsoft.Data.SqlClient.SqlConnection.SqlConfigurableRetryFactory.CreateNoneRetryProvider` will be used instead.
154
+
> Any errors when reading an application configuration file for retry logic settings won't cause errors in the application. The default <xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateNoneRetryProvider%2A?displayProperty=nameWithType> will be used instead.
155
155
>
156
156
> You can use event source tracing to verify or troubleshoot issues with configuring retry logic. For more information, see [Enable event tracing in SqlClient](enable-eventsource-tracing.md).
Copy file name to clipboardExpand all lines: docs/connect/ado-net/configurable-retry-logic-core-apis-sqlclient.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,9 +20,9 @@ If the built-in retry logic providers don't cover your needs, you can create you
20
20
21
21
The built-in providers are designed around three interfaces that can be used to implement custom providers. Custom retry providers can then be used in the same way as internal retry providers on a <xref:Microsoft.Data.SqlClient.SqlConnection> or <xref:Microsoft.Data.SqlClient.SqlCommand>:
22
22
23
-
1.`Microsoft.Data.SqlClient.SqlRetryIntervalBaseEnumerator`: Generates a sequence of time intervals.
24
-
2.`Microsoft.Data.SqlClient.SqlRetryLogicBase`: Retrieves the next time interval for a given enumerator, if the number of retries has not been exceeded and a transient condition is met.
25
-
3.`Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider`: Applies retry logic to connection and command operations.
23
+
1.<xref:Microsoft.Data.SqlClient.SqlRetryIntervalBaseEnumerator>: Generates a sequence of time intervals.
24
+
2.<xref:Microsoft.Data.SqlClient.SqlRetryLogicBase>: Retrieves the next time interval for a given enumerator, if the number of retries has not been exceeded and a transient condition is met.
25
+
3.<xref:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider>: Applies retry logic to connection and command operations.
26
26
27
27
> [!CAUTION]
28
28
> By implementing a custom retry logic provider, you're in charge of all aspects, including concurrency, performance, and exception management.
@@ -63,7 +63,7 @@ The implementation in this sample is as simple as possible to demonstrate step-b
- Assign the retry provider to the `Microsoft.Data.SqlClient.SqlConnection.RetryLogicProvider` or `Microsoft.Data.SqlClient.SqlCommand.RetryLogicProvider`:
66
+
- Assign the retry provider to the <xref:Microsoft.Data.SqlClient.SqlConnection.RetryLogicProvider%2A?displayProperty=nameWithType> or <xref:Microsoft.Data.SqlClient.SqlCommand.RetryLogicProvider%2A?displayProperty=nameWithType>:
Copy file name to clipboardExpand all lines: docs/connect/ado-net/configurable-retry-logic-sqlclient-introduction.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -23,7 +23,7 @@ Configurable retry logic lets developers and administrators manage application b
23
23
This feature consists of three main components:
24
24
25
25
1.**Core APIs**: Developers can use these interfaces to implement their own retry logic on <xref:Microsoft.Data.SqlClient.SqlConnection> and <xref:Microsoft.Data.SqlClient.SqlCommand> objects. For more information, see [Configurable retry logic core APIs in SqlClient](configurable-retry-logic-core-apis-sqlclient.md).
26
-
2.**Pre-defined configurable retry logic**: Built-in retry logic methods using the core APIs are accessible from the `Microsoft.Data.SqlClient.SqlConfigurableRetryFactory` class. For more information, see [Internal retry logic providers in SqlClient](internal-retry-logic-providers-sqlclient.md).
26
+
2.**Pre-defined configurable retry logic**: Built-in retry logic methods using the core APIs are accessible from the <xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory> class. For more information, see [Internal retry logic providers in SqlClient](internal-retry-logic-providers-sqlclient.md).
27
27
3.**Configuration file schema**: To specify the default retry logic for <xref:Microsoft.Data.SqlClient.SqlConnection> and <xref:Microsoft.Data.SqlClient.SqlCommand> in an application. For more information, see [Configurable retry logic configuration file with SqlClient](configurable-retry-logic-config-file-sqlclient.md).
28
28
29
29
## Quick start
@@ -32,22 +32,22 @@ To use this feature, follow these four steps:
32
32
33
33
1. Enable the safety switch in the preview version. For information on how to enable the AppContext safety switch, see [Enable configurable retry logic](appcontext-switches.md#enable-configurable-retry-logic).
34
34
35
-
2. Define the retry logic options using `Microsoft.Data.SqlClient.SqlRetryLogicOption`.
35
+
2. Define the retry logic options using <xref:Microsoft.Data.SqlClient.SqlRetryLogicOption>.
36
36
In this sample, some of the retry parameters are set and the rest of them will use the default values.
4. Assign the `Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider` instance to the `Microsoft.Data.SqlClient.SqlConnection.RetryLogicProvider` or `Microsoft.Data.SqlClient.SqlCommand.RetryLogicProvider`.
45
-
In this sample, the connection open command will retry if it hits one of the transient errors in the `Microsoft.Data.SqlClient.SqlConfigurableRetryFactory` internal list for a maximum of five times.
44
+
4. Assign the <xref:Microsoft.Data.SqlClient.SqlRetryLogicBaseProvider> instance to the <xref:Microsoft.Data.SqlClient.SqlConnection.RetryLogicProvider%2A?displayProperty=nameWithType> or <xref:Microsoft.Data.SqlClient.SqlCommand.RetryLogicProvider%2A?displayProperty=nameWithType>.
45
+
In this sample, the connection open command will retry if it hits one of the transient errors in the <xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory> internal list for a maximum of five times.
> These steps are the same for a command execution, except you would instead assign the retry provider to the `Microsoft.Data.SqlClient.SqlCommand.RetryLogicProvider` property before executing the command.
50
+
> These steps are the same for a command execution, except you would instead assign the retry provider to the <xref:Microsoft.Data.SqlClient.SqlCommand.RetryLogicProvider%2A?displayProperty=nameWithType> property before executing the command.
Built-in, internal retry providers have been implemented for the most common retry patterns. You can use the retry providers by using the following `Microsoft.Data.SqlClient.SqlConfigurableRetryFactory` static methods:
19
+
Built-in, internal retry providers have been implemented for the most common retry patterns. You can use the retry providers by using the following <xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory?displayProperty=fullName> static methods:
> All of the internal retry providers slightly randomize interval gap times before each retry. This randomization avoids hitting the database at the same time when multiple clients are trying to connect or execute a command with the same configuration.
28
28
29
29
> [!WARNING]
30
30
> Internal retry providers don't support retrying on a command that executes in an open transaction. That operation will execute without retry logic. You can override this behavior by using custom retry logic. For more information, see [Configurable retry logic core APIs in SqlClient](configurable-retry-logic-core-apis-sqlclient.md).
31
31
32
-
<!-- These links won't be live until after the feature is released in a GA version.
33
32
## Example
34
33
35
34
You can find samples for `connection` and `command` retry logic at the following links:
0 commit comments