1

我在我的应用程序中使用 Java couchbase sdk。在设置DefaultCouchbaseEnvironment时,我遇到了RetryStrategy属性。现在我使用重试策略为BestEffortRetryStrategy的默认配置。根据文档

BestEffortRetryStrategy will retry the operation until it either succeeds or the maximum request lifetime is reached

默认情况下,最大请求生命周期为 75 秒。

现在我想在这里理解的是重试在这里意味着什么。重试是否意味着在发生异常时重试请求,或者是否意味着它将重试将此请求分配给某个节点以处理请求,以防它不能并且它将继续重试 75 秒?

我正在查看我的应用程序日志中的不同异常以了解这一点,我可以看到TemporaryFailureException没有重试,我还可以看到在某些情况下RequestCancelledException在 75 秒后被抛出。假设 couchbase 重试请求以将其分配给节点以处理它,并且一旦它到达将处理此请求的节点,它实际上不会重试任何异常?

StackTrace for TemporaryFailureException-

stackTrace: com.couchbase.client.java.error.TemporaryFailureException: null
    at com.couchbase.client.java.bucket.api.Mutate$2$1.call(Mutate.java:246)
    at com.couchbase.client.java.bucket.api.Mutate$2$1.call(Mutate.java:220)
    at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:69)
    at rx.observers.Subscribers$5.onNext(Subscribers.java:235)
    at rx.internal.operators.OnSubscribeDoOnEach$DoOnEachSubscriber.onNext(OnSubscribeDoOnEach.java:101)
    at rx.internal.producers.SingleProducer.request(SingleProducer.java:65)
    at rx.Subscriber.setProducer(Subscriber.java:211)
    at rx.internal.operators.OnSubscribeMap$MapSubscriber.setProducer(OnSubscribeMap.java:102)
    at rx.Subscriber.setProducer(Subscriber.java:205)
    at rx.internal.operators.OnSubscribeMap$MapSubscriber.setProducer(OnSubscribeMap.java:102)
    at rx.Subscriber.setProducer(Subscriber.java:205)
    at rx.Subscriber.setProducer(Subscriber.java:205)
    at rx.subjects.AsyncSubject.onCompleted(AsyncSubject.java:103)
    at com.couchbase.client.core.endpoint.AbstractGenericHandler.completeResponse(AbstractGenericHandler.java:508)
    at com.couchbase.client.core.endpoint.AbstractGenericHandler.access$000(AbstractGenericHandler.java:86)
    at com.couchbase.client.core.endpoint.AbstractGenericHandler$1.call(AbstractGenericHandler.java:526)
    at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java)
    at java.lang.Thread.run(Thread.java:748)
Caused by: rx.exceptions.OnErrorThrowable$OnNextValue: OnError while emitting onNext value: com.couchbase.client.core.message.kv.UpsertResponse.class
    at rx.exceptions.OnErrorThrowable.addValueAsLastCause(OnErrorThrowable.java:118)
    at rx.internal.operators.OnSubscribeMap$MapSubscriber.onNext(OnSubscribeMap.java:73)
    ... 21 common frames omitted```
4

1 回答 1

0

BestEffortRetryStrategy 应该重试,直到请求被超时取消。FailFastRetryStrategy 不应重试。它应该立即失败。

如果您有 TemporaryFailureException 并且有 BestEffortRetryStrategy,则应该重试。如果你有一个没有重试,你可以分享堆栈跟踪吗?

  • 麦克风
于 2020-04-28T19:03:21.590 回答