我必须更新 Cassandra 表中的数千条记录,并且我使用 executeAsync(BoundStatement)
方法,但是我收到错误消息 Pool is busy (no available connection and the queue has reached它的最大尺寸为 256)
请参阅下面的完整详细信息。$
正确处理此类执行的最佳方法是什么?增加 Cassandra 查询队列大小和队列中的等待时间怎么样?
Exception in thread "Thread-6" com.datastax.driver.core.exceptions.NoHostAvailableException: All host(s) tried for query failed (tried: cassandra2/172.18.0.17:9042 (com.datastax.driver.core.exceptions.BusyPoolException: [cassandra2/172.18.0.17] Pool is busy (no available connection and the queue has reached its max size 256)), cassandra4/172.18.0.18:9042 (com.datastax.driver.core.exceptions.BusyPoolException: [cassandra4/172.18.0.18] Pool is busy (no available connection and the queue has reached its max size 256)), cassandra1/172.18.0.11:9042 (com.datastax.driver.core.exceptions.BusyPoolException: [cassandra1/172.18.0.11] Pool is busy (no available connection and the queue has reached its max size 256)))
at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:75)
at com.datastax.driver.core.exceptions.NoHostAvailableException.copy(NoHostAvailableException.java:28)
at com.datastax.driver.core.DriverThrowables.propagateCause(DriverThrowables.java:28)
at com.datastax.driver.core.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:236)
我使用的集群有 3 个节点,QUORUM 一致性和复制因子为 3。
最佳答案
有两种选择:
- 调整 connection pool为您的集群实现最佳性能
- 限制异步查询的数量以避免 NoHostAvailableException。例如。作为described here
关于java - 正确处理大量异步查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49685400/