Idempotent Requests
Idempotency is important in APIs because a resource may be called multiple times if an operation times out or encounters other server issues before it completes. If the original request and the subsequent retries are successful, the operation is completed multiple times. This means that you might create more resources than you intended.
To solve this problem, idempotent request identifiers are introduced to distinguish the first attempt from subsequent attempts. With an idempotent request, if the original request completes successfully, any subsequent retries complete successfully without performing any further actions.
Currently, idempotency is only available to the API for creating RDS for MySQL single and primary/standby instances in Creating a DB Instance.
Idempotency
An idempotent operation produces the same result even when the operation is repeated many times.
Idempotency in RDS APIs
When sending a request, the client can add X-Client-Token to the HTTP header as the idempotency identifier. For details, see Table 1.
Parameter |
Description |
Mandatory |
Example Value |
---|---|---|---|
X-Client-Token |
Identifier that ensures idempotency of client requests. It is a UUID containing 32 hexadecimal digits and is generated by the client. The value must be unique. |
No |
46436810-d999-454c-bd85-e515fd258600 |
Generally, the client resends the request only when the response status code is 5xx due to an internal server exception or connection timeout or when the response result cannot be obtained. If the retry request uses the same idempotent identifier and request parameters, the server will return the same result as the original request.
Description about idempotency identifiers:
- An idempotency identifier is a case-sensitive UUID containing 32 hexadecimal digits. It is in the format of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx (8-4-4-4-12), where each x is a hexadecimal digit ranging from 0 to 9 or a to f. If you provide an identifier that is not in UUID format, the server returns error code DBS.280497.
- Idempotency identifiers must be unique. If you reuse an identifier with different parameters, the server returns error code DBS.280495.
- Idempotent identifiers remain valid for eight hours. If an identifier has expired, the server returns error code DBS.280498.
- After an idempotency identifier is used:
- If the returned status code is 2xx, subsequent retries will return the same result as the original one without affecting the server status.
- If the returned status code is 4xx, subsequent retries will fail. You need to rectify the fault based on the error information and retry the request.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot