Example #1
0
        public static void CommandFailureRetry(RetryState retryState, string commandKeyword)
        {
            Logger.Write(TraceEventType.Information, string.Format(
                             CultureInfo.InvariantCulture,
                             "{0} retry number {1}. Delaying {2} ms before retry. Exception: {3}",
                             commandKeyword,
                             retryState.RetryCount,
                             retryState.Delay.TotalMilliseconds.ToString(CultureInfo.InvariantCulture),
                             retryState.LastError.ToString()));

            RetryPolicyUtils.RaiseAmbientRetryMessage(retryState, SqlSchemaModelErrorCodes.ServiceActions.CommandRetry);
        }
Example #2
0
            protected override bool ShouldRetryImpl(RetryState retryState)
            {
                Contract.Assert(retryState != null);

                if (IsLessThanMaxRetryCount(retryState.RetryCount, _maxRetryCount))
                {
                    retryState.Delay = RetryPolicyUtils.CalcExponentialRetryDelay(retryState.RetryCount, _intervalFactor, _minInterval, _maxInterval);
                    return(true);
                }

                retryState.Delay = TimeSpan.Zero;
                return(false);
            }
Example #3
0
            protected override bool CanRetrySqlException(SqlException sqlException)
            {
                // Enumerate through all errors found in the exception.
                foreach (SqlError err in sqlException.Errors)
                {
                    RetryPolicyUtils.AppendThrottlingDataIfIsThrottlingError(sqlException, err);
                    if (RetryPolicyUtils.IsNonRetryableDataTransferError(err.Number))
                    {
                        Logger.Write(TraceEventType.Error, string.Format(Resources.ExceptionCannotBeRetried, err.Number, err.Message));
                        return(false);
                    }
                }

                // Default is to treat all SqlException as retriable.
                return(true);
            }
Example #4
0
            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);
            }
Example #5
0
 private void RetryConnectionCallback(RetryState retryState)
 {
     RetryPolicyUtils.RaiseSchemaAmbientRetryMessage(retryState, SqlSchemaModelErrorCodes.ServiceActions.ConnectionRetry, _azureSessionId);
 }