mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-14 09:59:48 -05:00
* Initial commit of reliable connection port * Made ReliableSqlConnection inherit from DbConnection instead of IDbConnection * Cleanup * Fixed autocomplete service to use reliable connection * Fix copyright headers * Renamed ConnectResponse.Server to ServerInfo * Removed unused using * Addressing code review feedback
44 lines
1.7 KiB
C#
44 lines
1.7 KiB
C#
//
|
|
// Copyright (c) Microsoft. All rights reserved.
|
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
//
|
|
|
|
using System.Data.SqlClient;
|
|
|
|
namespace Microsoft.SqlTools.ServiceLayer.Connection.ReliableConnection
|
|
{
|
|
internal abstract partial class RetryPolicy
|
|
{
|
|
/// <summary>
|
|
/// Provides the error detection logic for temporary faults that are commonly found in SQL Azure.
|
|
/// The same errors CAN occur on premise also, but they are not seen as often.
|
|
/// </summary>
|
|
internal sealed class NetworkConnectivityErrorDetectionStrategy : ErrorDetectionStrategyBase, IErrorDetectionStrategy
|
|
{
|
|
private static NetworkConnectivityErrorDetectionStrategy instance = new NetworkConnectivityErrorDetectionStrategy();
|
|
|
|
public static NetworkConnectivityErrorDetectionStrategy Instance
|
|
{
|
|
get { return instance; }
|
|
}
|
|
|
|
protected override bool CanRetrySqlException(SqlException sqlException)
|
|
{
|
|
// Enumerate through all errors found in the exception.
|
|
bool foundRetryableError = false;
|
|
foreach (SqlError err in sqlException.Errors)
|
|
{
|
|
RetryPolicyUtils.AppendThrottlingDataIfIsThrottlingError(sqlException, err);
|
|
if (!RetryPolicyUtils.IsRetryableNetworkConnectivityError(err.Number))
|
|
{
|
|
// If any error is not retryable then cannot retry
|
|
return false;
|
|
}
|
|
foundRetryableError = true;
|
|
}
|
|
return foundRetryableError;
|
|
}
|
|
}
|
|
}
|
|
}
|