All Products
Search
Document Center

Tablestore:Error handling

Last Updated:Jul 05, 2024

Tablestore SDK for Java handles errors as exceptions. This topic describes the error handling method, exceptions, and retry policies of Tablestore SDK for Java.

Method

Tablestore SDK for Java handles errors as exceptions. If no exceptions are returned, the operation is successful. If an exception is returned, the operation fails.

Note

Batch operations such as BatchGetRow and BatchWriteRow are successful only if the system verifies that no exception is returned and the status of each row is successful.

Exceptions

ClientException and TableStoreException are common exceptions you may encounter when you use Tablestore SDK for Java. The two exceptions are inherited from RuntimeException.

  • ClientException: an internal SDK exception such as an invalid parameter value.

  • TableStoreException: a server error parsed from a server error message. TableStoreException provides the following information:

    • getHttpStatus(): an HTTP status code such as 200 or 404.

    • getErrorCode(): an error type string returned by Tablestore.

    • getRequestId(): the UUID that identifies the request. If you fail to resolve the issue, record the request ID and submit a ticket.

Retry policies

  • Tablestore SDK for Java automatically retries operations when an error occurs. In the default retry policy, the maximum retry period is 10s. Retries are performed for throttling errors and internal server errors related to read operations.

  • You can also specify a custom retry policy by inheriting the RetryStrategy class, and import the custom retry policy as parameters when you create an OTSClient object.

Tablestore SDK for Java provides the following retry policies:

  • DefaultRetryStrategy: the default retry policy that retries only read operations. The retry interval increases exponentially by 10 ms. The maximum retry period is 10s.

  • AlwaysRetryStrategy: retries all types of requests. The maximum number of retries is three. The retry interval increases exponentially by 4 ms. The maximum retry interval is 1s.