Skip to content

Latest commit

 

History

History
42 lines (31 loc) · 2.41 KB

File metadata and controls

42 lines (31 loc) · 2.41 KB
title Internal retry logic providers in SqlClient
description Learn how to use the built-in configurable retry logic providers in your application to handle transient errors against your database.
author David-Engel
ms.author davidengel
ms.reviewer v-deshtehari
ms.date 03/22/2021
ms.service sql
ms.subservice connectivity
ms.topic concept-article

Internal retry logic providers in SqlClient

[!INCLUDE dotnet-all]

[!INCLUDEDriver_ADONET_Download]

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:

  • xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateFixedRetryProvider%2A?displayProperty=nameWithType
  • xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateIncrementalRetryProvider%2A?displayProperty=nameWithType
  • xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateExponentialRetryProvider%2A?displayProperty=nameWithType
  • xref:Microsoft.Data.SqlClient.SqlConfigurableRetryFactory.CreateNoneRetryProvider%2A?displayProperty=nameWithType

Note

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.

Warning

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.

Example

You can find samples for connection and command retry logic at the following links:

  • xref:Microsoft.Data.SqlClient.SqlConnection.RetryLogicProvider%2A?displayProperty=nameWithType
  • xref:Microsoft.Data.SqlClient.SqlCommand.RetryLogicProvider%2A?displayProperty=nameWithType

See also