DowngradingConsistencyRetryPolicy ClassA C# client driver for Apache Cassandra
A retry policy that sometimes retry with a lower consistency level than the one initially requested.

BEWARE: This policy may retry queries using a lower consistency level than the one initially requested. By doing so, it may break consistency guarantees. In other words, if you use this retry policy, there is cases (documented below) where a read at

may not see a preceding write at . Do not use this policy unless you have understood the cases where this can happen and are ok with that. It is also highly recommended to always wrap this policy into LoggingRetryPolicy to log the occurences of such consistency break.

This policy : the same retries than the DefaultRetryPolicy policy. But on top of that, it also retries in the following cases:

  • On a read timeout: if the number of replica that responded is greater than one but lower than is required by the requested consistency level, the operation is retried at a lower concistency level.
  • On a write timeout: if the operation is an
    * WriteType.UNLOGGED_BATCH
    and at least one replica acknowleged the write, the operation is retried at a lower consistency level. Furthermore, for other operation, if at least one replica acknowleged the write, the timeout is ignored.
  • On an unavailable exception: if at least one replica is alive, the operation is retried at a lower consistency level.

The reasoning behing this retry policy is the following one. If, based on the information the Cassandra coordinator node returns, retrying the operation with the initally requested consistency has a change to succeed, do it. Otherwise, if based on these informations we know the initially requested consistency level cannot be achieve currently, then:

  • For writes, ignore the exception (thus silently failing the consistency requirement) if we know the write has been persisted on at least one replica.
  • For reads, try reading at a lower consistency level (thus silently failing the consistency requirement).
In other words, this policy : the idea that if the requested consistency level cannot be achieved, the next best thing for writes is to make sure the data is persisted, and that reading something is better than reading nothing, even if there is a risk of reading stale data.

Inheritance Hierarchy

OnlineSystem Object
  Cassandra DowngradingConsistencyRetryPolicy

Namespace: Cassandra
Assembly: Cassandra (in Cassandra.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax

public class DowngradingConsistencyRetryPolicy : IRetryPolicy
See Also