edit-icon download-icon

Retry

Last Updated: Mar 20, 2018

Common retry strategies

The SDK provides the following common retry strategies:

  • Default retry strategy

    An SDK error automatically triggers retries. The maximum retry interval is 10 seconds.

  • Counting retry strategy

    Retry at user-defined intervals. If the retry strategy is secure, the maximum number of retry attempts cannot exceed the user-defined number.

  • No retry

Custom retry strategy

You can customize your retry strategy by modifying RetryStrategy.

  1. class RetryStrategy
  2. {
  3. public:
  4. virtual ~RetryStrategy() {}
  5. virtual RetryStrategy* clone() const =0;
  6. virtual int64_t retries() const throw() =0;
  7. virtual bool shouldRetry(Action, const OTSError&) const =0;
  8. virtual util::Duration nextPause() =0;
  9. };
  • clone() replicates a new object. The new object must be of the same type and internal status (including the number of retries) as the current one.

  • retries(), number of already completed retries.

  • shouldRetry() specifies operations and errors to determine whether a retry is needed.

    Table Store provides two tool functions for easier operation:

    • The first retriable divides errors into three groups.

      • Completely harmless retries, such as OTSTableNotReady.
      • Harmful or meaningless retries, such as with parameter errors.
      • Cannot be judged based on errors alone, such as OTSRequestTimeout.
    • The second retriable determines whether a retry can be performed based on the idempotence principles of an operation, while also taking operations and errors into consideration. In other words, both RETRIABLE errors and the DEPENDS errors of a read operation are judged to be retriable.

      1. enum RetryCategory
      2. {
      3. UNRETRIABLE,
      4. RETRIABLE,
      5. DEPENDS,
      6. };
      7. static RetryCategory retriable(const OTSError&);
      8. static bool retriable(Action, const OTSError&);
  • nextPause() is the interval until the next retry, if retriable.
Thank you! We've received your feedback.