Skip to content

Can SqlConfigurableRetryProviders be re-used #2259

Description

@Vandersteen

Is it advised to always create a new retry provider for every connection / command or can they be re-used across many connections / commands. It is unclear from the documentation what the best practices are:

private static readonly SqlRetryLogicBaseProvider DefaultRetryProvider = SqlConfigurableRetryFactory.CreateIncrementalRetryProvider(
                new SqlRetryLogicOption()
                {
                    NumberOfTries = 5,
                    MaxTimeInterval = TimeSpan.FromSeconds(10)
                }
            );
            
//...

public IConnection GetConnection()
{
    var connection = new SqlConnection(_options.ConnectionString);
    connection.RetryLogicProvider = DefaultRetryProvider;
    return connection;
}

vs creating it for every connection

public IConnection GetConnection()
{
    var connection = new SqlConnection(_options.ConnectionString);
    connection.RetryLogicProvider = SqlConfigurableRetryFactory.CreateIncrementalRetryProvider(...);
    return connection;
}

Same thing goes for commands

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions