什么会导致准备好的查询中出现 "java.lang.IndexOutOfBoundsException: Index: 1, Size: 1"?

What can cause "java.lang.IndexOutOfBoundsException: Index: 1, Size: 1" in a prepared query?

这是在 Cassandra 3.11.4 中。

我正在 运行 修改之前在我的应用程序中运行良好的查询版本。原始查询是这样的:

SELECT SerializedRecord FROM SxRecord WHERE Mark=?

我将查询修改为具有时间戳范围(我还为其添加了索引,但我认为这不相关):

SELECT SerializedRecord FROM SxRecord WHERE Mark=? AND Timestamp>=? AND Timestamp<=?

这导致:

 ResponseError {reHost = datacenter1:rack1:127.0.0.1:9042, reTrace = Nothing, reWarn = [], reCause = ServerError "java.lang.IndexOutOfBoundsException: Index: 1, Size: 1"}

发生这种情况时,我没有看到查询 CQL 被记录在 system_traces.sessions,这很有趣,因为如果我将语法错误放入查询中,它仍然会被记录在那里。

此外,当我 运行 在 cqlsh 中查询(据我所知,相同,直到时间戳)时,似乎没有问题:

cqlsh> SELECT SerializedRecord FROM test_fds.SxRecord WHERE Mark=8391 AND Timestamp >= '2021-03-06 00:00:00.000+0000' AND Timestamp <= '2021-03-09 00:00:00.000+0000';

 serializedrecord
------------------

这导致以下查询跟踪:

cqlsh> select parameters from system_traces.sessions;

 parameters
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
 {'consistency_level': 'ONE', 'page_size': '100', 'query': 'SELECT SerializedRecord FROM test_fds.SxRecord WHERE Mark=8391 AND Timestamp >= ''2021-03-06 00:00:00.000+0000'' AND Timestamp <= ''2021-03-09 00:00:00.000+0000'';', 'serial_consistency_level': 'SERIAL'}
                                                                                                                                                                                                                                                                   null

似乎在 prepared/bound 语句中执行的查询没有接收到所有需要的参数或接收到太多参数(在前面的代码中绑定的东西)

您看不到跟踪的查询是因为驱动程序甚至不执行查询,因为它具有未绑定的参数