问题描述
我正在尝试与Java的ExecutorService并行执行多个BatchSatements。我想知道我的查询是否成功执行。
我经历过: how do I find out if the update query was successful or not in Cassandra Datastax
这是说,如果没有例外,我们可以认为它是成功的。但是我收到了NoHostAvailableException。
All host(s) tried for query failed (tried: *********************(com.datastax.driver.core.exceptions.OperationTimedOutException: [******************] Timed out waiting for server response))
但是我可以在Cassandra中看到我的数据。我想知道如何在Cassandra中成功创建我的文档。有什么办法吗?
解决方法
与关系数据库相比,Cassandra中的批次不同。而且,它们仅应在limited number of the use cases中使用,并且在真正有必要之前,不应将它们用于批量插入/更新多个分区(请参阅“ misuse of batches”文档)。
即使您将错误返回给驱动程序,也将最终重播批处理-发生这种情况是因为批处理在执行之前已复制到其他节点。有关详细信息,请参见following diagram。