提问人:kkurt 提问时间:10/5/2023 更新时间:10/5/2023 访问量:32
如何在 Couchbase-Spark 连接器中设置 FailFastRetryStrategy 并避免无限重试循环?
How to Set FailFastRetryStrategy and Avoid Infinite Retry Loop in Couchbase-Spark Connector?
问:
我正在使用 Couchbase-Spark 连接器 (couchbase-spark-connector),并面临一个问题,即如果 Couchbase 实例在 Spark 作业运行时未运行或断开连接,应用程序将进入无限重试循环。我观察到重试机制不断尝试重新连接到 Couchbase,导致日志充斥着 TimeoutException 和 EndpointConnectionFailedEvent 错误。下面是日志的片段以供参考:
[info] 15:14:46.305|WARN | com.couchbase.endpoint [...] TimeoutException: Did not observe any item or terminal signal within 1000ms in 'source(MonoDefer)' (and no fallback has been configured)
[info] 15:14:47.322|WARN | com.couchbase.endpoint [...] Connect attempt 1 failed because of TimeoutException: Did not observe any item or terminal signal within 1000ms in 'source(MonoDefer)' (and no fallback has been configured)
...
[info] 15:14:47.322|WARN | com.couchbase.endpoint [...] Connect attempt 100 failed because of TimeoutException: Did not observe any item or terminal signal within 1000ms in 'source(MonoDefer)' (and no fallback has been configured)
我怀疑此行为受重试策略控制。默认情况下,Couchbase-Spark 连接器使用 BestEffortRetryStrategy,这似乎会导致此无限重试循环。我想将其更改为 FailFastRetryStrategy 以避免这种情况,并确保在无法访问 Couchbase 时作业快速失败。
我尝试在Spark配置中设置重试策略,如下所示:
val sparkConf = new SparkConf()
.setAppName("test")
.set("spark.couchbase.retryStrategy", "FailFastRetry")
但是,这会导致错误:
Caused by: com.couchbase.client.core.error.InvalidArgumentException: Expected a value Jackson can bind to interface com.couchbase.client.core.retry.RetryStrategy but got "FailFastRetry".
如何在 Couchbase-Spark 连接器中正确设置 FailFastRetryStrategy,以避免这种无限重试循环,并确保在无法访问 Couchbase 时我的 Spark 作业快速失败?
答: 暂无答案
评论