Retry policies

Retry policies allow the DataStax drivers to automatically retry a request upon encountering specific types of server errors.

Retry policies allow the DataStax drivers to automatically retry a request upon encountering specific types of server errors: In these scenarios, a node is designated as a coordinator for the request by the load balancing policy. The coordinator routes the request to the replicas and returns the response to the driver.

Each DataStax driver implements a default retry policy.

Table 1. Retry policies for drivers
C/C++ C# Java Node.js PHP Python Ruby

Along with the driver-included retry policies, some drivers allow extended retry policies to implement custom behavior based on read timeout, write timeout, unavailable exceptions, and request errors.

Default retry policy

The default retry policy retries a request when it is safe to do so while preserving the consistency level of the original request. Use this policy for most deployments.

Read timeout

If the number of replicas that reply is greater than or equal to the number of required responses per the consistency level, the default retry policy retries the request. In all other cases, it returns an error.

Figure 1: Read timeout

Read timeout

Write timeout

If the request is a logged batch request and fails to write to the batch log, the default retry policy retries the request. In all other cases, it returns an error.

Figure 2: Write timeout

Write timeout

Unavailable errors

If the request encounters an unavailable error, the default retry policy retries the request using the next host in the load balancing policy.

Figure 3: Unavailable errors

Unavailable

Fall-through retry policy

The fall-through retry policy never retries or ignores a failed request. In all cases, the fall-through retry policy returns an error. Use this policy for applications that need to implement their own business logic to handle retrying a request.

Figure 4: Fall through retry

Fall through retry

Logging retry policy

The logging retry policy is intended to be a parent policy for another retry policy implementation and only logs the retry decision made by its child policy. This policy is typically used to debug driver retry behavior.

Figure 5: Logging retry policy

Logging retry