Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

Tonny avatar image
Tonny asked ·

driver 请求重试次数 和 机制

cassandra java driver 3.6版本,当请求发生OverloadedException异常时,发现有重试机制。未显示配置重试策略。

对于默认重试策略,java driver的重试机制和重试次数分别是什么?其他语言的driver(python, go等)的重试机制和java的相同吗?不同的话重试次数和机制分别是什么

driver
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

Erick Ramirez avatar image
Erick Ramirez answered ·

When the driver runs a query, the configured load balancing policy computes a query plan (a list of nodes to connect to). The driver tries each of the hosts in the query plan based on the retry policy.

If a coordinator can't be reached or returns an error, the driver will either:

  • retry the query on the same node,
  • retry the query on the next node in the query plan,
  • return the exception to the application, or
  • return an empty result.

In the case where the coordinator returns an OverloadedException, the DefaultRetryPolicy will retry the request on the next node in the query plan.

The number of retries isn't fixed since it depends on the outcome of each attempt.

In general, the retry mechanism is the same for DataStax drivers but I can't comment on other drivers such as GoCQL since it is not maintained by DataStax.

For more details, see the Java driver 3.6 Retry Policy. Cheers!

2 comments Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

thank you for you apply.


In the case where the coordinator returns an OverloadedException, the DefaultRetryPolicy will retry the request on the next node in the query plan.

他会在其他节点继续重试执行查询,如果每个节点都抛`OverloadedException`,假如都是单副本集群,对于3节点集群,会重试3次?对于5节点集群,那么重试5次?以此类推?或者是不是有个重试上限,比如最多重试几次或者driver自己是否有查询请求的超时时间?

0 Likes 0 · ·

The driver will try to connect to the nodes in the query plan. It will not always retry the request unless the RetryPolicy.RetryDecision determines that the next action is to retry. You can't assume that the driver will repeatedly try the next host until it runs out of nodes to try.

For example, if the coordinator node returns a READ_TIMEOUT error to the driver and the query has not been retried before, the DefaultRetryPolicy will retry again on the same node. But if the query has already been retried once, the driver will throw a ReadTimeoutException to the application.

Specifically for the DefaultRetryPolicy, it will only retry once. You can see the details of the RetryDecision for the DefaultRetryPolicy here. Cheers!

0 Likes 0 · ·