Class DefaultRetryPolicy
The default retry policy.
This policy retries queries in only two cases:
- On a read timeout, if enough replica replied but data was not retrieved.
- On a write timeout, if we timeout while writting the distributed log used by batch statements.
This retry policy is conservative in that it will never retry with a different consistency level than the one of the initial operation.
In some cases, it may be convenient to use a more aggressive retry policy like DowngradingConsistencyRetryPolicy.
Inheritance
Inherited Members
Namespace: Cassandra
Assembly: Cassandra.dll
Syntax
public class DefaultRetryPolicy : IExtendedRetryPolicy, IRetryPolicy
Methods
OnReadTimeout(IStatement, ConsistencyLevel, int, int, bool, int)
Defines whether to retry and at which consistency level on a read timeout.
This method triggers a maximum of one retry, and only if enough replica had responded to the read request but data was not retrieved amongst those. Indeed, that case usually means that enough replica are alive to satisfy the consistency but the coordinator picked a dead one for data retrieval, not having detected that replica as dead yet. The reasoning for retrying then is that by the time we get the timeout the dead replica will likely have been detected as dead and the retry has a high change of success.
Declaration
public RetryDecision OnReadTimeout(IStatement query, ConsistencyLevel cl, int requiredResponses, int receivedResponses, bool dataRetrieved, int nbRetry)
Parameters
Type | Name | Description |
---|---|---|
IStatement | query | the original query that timed out. |
ConsistencyLevel | cl | the original consistency level of the read that timed out. |
int | requiredResponses | the number of responses that were required to achieve the requested consistency level. |
int | receivedResponses | the number of responses that had been received by the time the timeout exception was raised. |
bool | dataRetrieved | whether actual data (by opposition to data checksum) was present in the received responses. |
int | nbRetry | the number of retry already performed for this operation. |
Returns
Type | Description |
---|---|
RetryDecision |
|
OnRequestError(IStatement, Configuration, Exception, int)
The default implementation triggers a retry on the next host in the query plan with the same consistency level, regardless of the statement's idempotence, for historical reasons.
Declaration
public RetryDecision OnRequestError(IStatement statement, Configuration config, Exception ex, int nbRetry)
Parameters
Type | Name | Description |
---|---|---|
IStatement | statement | |
Configuration | config | |
Exception | ex | |
int | nbRetry |
Returns
Type | Description |
---|---|
RetryDecision |
OnUnavailable(IStatement, ConsistencyLevel, int, int, int)
Defines whether to retry and at which consistency level on an unavailable exception.
This method never retries as a retry on an unavailable exception using the same consistency level has almost no change of success.
Declaration
public RetryDecision OnUnavailable(IStatement query, ConsistencyLevel cl, int requiredReplica, int aliveReplica, int nbRetry)
Parameters
Type | Name | Description |
---|---|---|
IStatement | query | the original query for which the consistency level cannot be achieved. |
ConsistencyLevel | cl | the original consistency level for the operation. |
int | requiredReplica | the number of replica that should have been (known) alive for the operation to be attempted. |
int | aliveReplica | the number of replica that were know to be alive by the coordinator of the operation. |
int | nbRetry | the number of retry already performed for this operation. |
Returns
Type | Description |
---|---|
RetryDecision |
|
OnWriteTimeout(IStatement, ConsistencyLevel, string, int, int, int)
Defines whether to retry and at which consistency level on a write timeout.
This method triggers a maximum of one retry, and only in the case of a
WriteType.BATCH_LOG
write. The reasoning for the retry in that
case is that write to the distributed batch log is tried by the coordinator
of the write against a small subset of all the node alive in the local
datacenter. Hence, a timeout usually means that none of the nodes in that
subset were alive but the coordinator hasn't' detected them as dead. By the
time we get the timeout the dead nodes will likely have been detected as dead
and the retry has thus a high change of success.
Declaration
public RetryDecision OnWriteTimeout(IStatement query, ConsistencyLevel cl, string writeType, int requiredAcks, int receivedAcks, int nbRetry)
Parameters
Type | Name | Description |
---|---|---|
IStatement | query | the original query that timeouted. |
ConsistencyLevel | cl | the original consistency level of the write that timeouted. |
string | writeType | the type of the write that timeouted. |
int | requiredAcks | the number of acknowledgments that were required to achieve the requested consistency level. |
int | receivedAcks | the number of acknowledgments that had been received by the time the timeout exception was raised. |
int | nbRetry | the number of retry already performed for this operation. |
Returns
Type | Description |
---|---|
RetryDecision |
|