Example #1
0
        protected override bool ShouldRetryOn(Exception exception)
        {
            if (exception == null)
            {
                return(false);
            }

            MySqlException   myex      = exception as MySqlException;
            BackoffAlgorithm algorithm = null;

            if (myex != null && errorsToRetryOn.TryGetValue(myex.Number, out algorithm))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Example #2
0
        protected override TimeSpan?GetNextDelay(Exception lastException)
        {
            MySqlTraceCustom.LogInformation(1, "Re");
            MySqlException   myex      = lastException as MySqlException;
            BackoffAlgorithm algorithm = null;

            if (!errorsToRetryOn.TryGetValue(myex.Number, out algorithm))
            {
                // This must never happen
                throw new InvalidOperationException(string.Format("Trying to retry for non transient exception number: {0}, message: {1}", myex.Number, myex.Message));
            }
            TimeSpan?ts = algorithm.GetNextDelay();

            if (ts != null)
            {
                MySqlTraceCustom.LogInformation(1, string.Format("Retrying query for exception {0}", myex));
            }
            return(ts);
        }