All Products
Search
Document Center

Tablestore:Error handling

Last Updated:Aug 02, 2024

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

Error handling methods

Tablestore SDK for Python handles errors as exceptions. If an operation does not throw an exception, the operation is successful. If an operation throws an exception, 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

When you use Tablestore SDK for Python, the OTSClientError and OTSServiceError exceptions may occur. The two types of exceptions are inherited from Exception.

  • OTSClientError: an internal SDK exception, such as an invalid parameter value or a failure to parse the results returned by the server.

  • OTSServiceError: a server error. When a server error occurs, the server parses and returns the error message to the client. OTSServiceError provides the following information:

    • get_http_status: an HTTP status code such as 200 and 404.

    • get_error_code: an error type string returned by Tablestore.

    • get_error_message: an error message string returned by Tablestore.

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

Retry policies

  • Tablestore SDK for Python automatically retries operations when an error occurs. In the default retry policy, the maximum retry attempts is 20, and the maximum retry interval is 3,000 milliseconds. For information about the retry policies for throttling errors and internal server errors related to write operations, see tablestore/retry.py.

  • You can also customize a retry policy by inheriting the RetryPolicy class, and pass in the custom retry policy when you construct an OTSClient object.

Tablestore SDK for Python provides the following retry policies:

  • DefaultRetryPolicy: the default retry policy. Only read operations are retried. The maximum number of retry attempts is 20, and the maximum retry interval is 3,000 milliseconds.

  • NoRetryPolicy: No operation is retried.

  • NoDelayRetryPolicy: a retry policy without delay. Exercise caution when you use this policy.

  • WriteRetryPolicy: Read and write operations are retried.