一致性级别出现Cassandra写入超时异常。LOCAL_QUORUM

kmpatx3s  于 2022-11-05  发布在  Cassandra
关注(0)|答案(1)|浏览(304)

I am facing WriteTimeOutException while writing to Cassandra using CassandraSinkConnector at ConsistencyLevel.LOCAL_QUORUM.
I am using Cassandra 3.3.0 version
So i need help how to handle and fix this exception?

Stack-Trace:-

WorkerSinkTask due to unrecoverable exception.org.apache.kafka.connect.runtime.WorkerSinkTask.deliverMessages(WorkerSinkTask.java:546) org.apache.kafka.connect.runtime.WorkerSinkTask.poll(WorkerSinkTask.java:302)org.apache.kafka.connect.runtime.WorkerSinkTask.iteration(WorkerSinkTask.java:205)org.apache.kafka.connect.runtime.WorkerSinkTask.execute(WorkerSinkTask.java:173)org.apache.kafka.connect.runtime.WorkerTask.doRun(WorkerTask.java:170)org.apache.kafka.connect.runtime.WorkerTask.run(WorkerTask.java:214)java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) java.util.concurrent.FutureTask.run(FutureTask.java:266) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) java.lang.Thread.run(Thread.java:745) **Caused by: org.apache.kafka.connect.errors.ConnectException: com.datastax.driver.core.exceptions.WriteTimeoutException: Cassandra timeout during write query at consistency LOCAL_QUORUM (2 replica were required but only 1 acknowledged the write)** cassandra.sink.CassandraSinkTask.put(CassandraSinkTask.java:65)\n\tat org.apache.kafka.connect.runtime.WorkerSinkTask.deliverMessages(WorkerSinkTask.java:524)\n\t... 10 more\nCaused by: com.datastax.driver.core.exceptions.WriteTimeoutException: Cassandra timeout during write query at consistency LOCAL_QUORUM (2 replica were required but only 1 acknowledged the write)\n\tat

Driver Configuration:-

String user="test";
String password="test1234";

cluster = Cluster.builder()
                        .addContactPoints("some host address")
                        .withPort("1234")
                        .withQueryOptions(new QueryOptions().setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM))
                        .withCredentials(user, password)
                        .withSocketOptions(
                                new SocketOptions()
                                        .setConnectTimeoutMillis(15000)
                                        .setReadTimeoutMillis(0))
                        .build();
                session = cluster.connect();
0vvn1miw

0vvn1miw1#

仅当DataCenter中有多个节点时才会发生这种情况。当您尝试使用LOCAL_QUORUM进行写入时,(Total/2)+1个节点应可用于写入数据。
假设在写入过程中,3个节点中有2个发生故障。在这种情况下,您将得到上述错误。
现在有一种可能性,一旦你将看到节点:它们将显示为UP,但**由于节点在随机时间出现高负载,**一旦该节点上的负载正常,它们将自动显示为UP。
所以你应该在收到这个错误的同时检查负载,内存使用情况或者CPU使用情况。理想情况下,你可以使用Opsceter来监控这些事情。

相关问题