Example #1
0
        internal static void CommandFailureRetry(RetryState retryState, string commandKeyword)
        {
            Logger.Instance.Write(LogLevel.Normal, 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;
            }
            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.IsRetryableAzureError(err.Number))
                    {
                        // If any error is not retryable then cannot retry
                        return(false);
                    }
                    foundRetryableError = true;
                }
                return(foundRetryableError);
            }
 private void RetryConnectionCallback(RetryState retryState)
 {
     RetryPolicyUtils.RaiseSchemaAmbientRetryMessage(retryState, SqlSchemaModelErrorCodes.ServiceActions.ConnectionRetry, _azureSessionId);
 }