读取期间的 Cassandra 错误 - NoHostAvailableException:尝试查询的所有主机失败(未尝试主机)

Cassandra error during read - NoHostAvailableException: All host(s) tried for query failed (no host was tried)

我查看了 this and this,但找不到任何解决方案。

我仅在读取查询期间收到 'no host was tried' 错误。写信给卡桑德拉工作正常。我正在使用 datastax cassandra java 驱动程序 - 3.3.0.

我正在尝试以下读取查询 'health-check':

SELECT * from counter_table;

一些创建集群的代码片段:

Cluster cluster = Cluster.builder()
    .addContactPointsWithPorts(convertToInternetAddress())
    .withAuthProvider(authProvider)
    .withPoolingOptions(poolingOptions)
    .withRetryPolicy(cassandraRetryPolicy)
    .build();

编辑 1:我更新了第一次出现此错误的示例查询。我在不提供任何分区键的情况下查询带有计数器字段的 table。但是,table

中只有5条记录

编辑 2:减少集群池超时似乎已经解决了这个问题。知道为什么吗?

我终于明白了。我正在使用多个会话,其中一个会话即将关闭。 使用已关闭会话的查询出现此错误。