Cassandra查询超时选择查询:
SELECT x, y FROM <table> WHERE unique_id= <value>
,例外
com.datastax.driver.core.exceptions.ReadTimeoutException: Cassandra timeout during read query at consistency ALL (3 responses were required but only 2 replica responded)
at com.datastax.driver.core.exceptions.ReadTimeoutException.copy(ReadTimeoutException.java:88)
at com.datastax.driver.core.exceptions.ReadTimeoutException.copy(ReadTimeoutException.java:25)
at com.datastax.driver.core.DriverThrowables.propagateCause(DriverThrowables.java:37)
at com.datastax.driver.core.DefaultResultSetFuture.getUninterruptibly(DefaultResultSetFuture.java:245)
Cassandra司机:
<dependency>
<groupId>com.datastax.cassandra</groupId>
<artifactId>cassandra-driver-core</artifactId>
<version>3.5.0</version>
</dependency>
我们的查询代码:
QueryOptions queryOptions = new QueryOptions();
queryOptions.setSerialConsistencyLevel(ConsistencyLevel.LOCAL_SERIAL);
queryOptions.setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM);
List<String> contactPoints = Utils
.getArrayStrings(config, Constants.CASSANDRA_CONTACT_POINTS);
Cluster cluster = Cluster.builder()
.addContactPoints(contactPoints.toArray(new String[contactPoints.size()]))
.withQueryOptions(queryOptions)
.withProtocolVersion(ProtocolVersion.V4)
.build();
Session session = cluster.connect();
session.executeAsync(SELECT_STATEMENT).bind()
.setUUID(0, UUID.fromString(inputEvent.getUniqueId()))
为什么在将查询选项的一致性设置为LOCAL_QUORUM时将一致性设置为ALL?
答案 0 :(得分:1)
我们在生产环境中遇到了同样的问题。似乎与CASSANDRA-10726中所述的读取修复过程有关。同样,在这个重复的CASSANDRA-14480错误中,其他人的行为也完全相同。
只有在切换到多DC环境后,我们才注意到此错误。
我们正在使用以下版本:
卡桑德拉:3.0.15 DSE:5.0.12 Java驱动程序:3.1.4
答案 1 :(得分:0)
它看起来非常像CASSANDRA-7947,如果在触发读取修复的查询中发生超时(使用ALL
执行),则报告为ALL
而不是原始{{1} }}。虽然这个bug应该已经在2.0.12 / 2.1.3中修复了......