所以这让我发疯。我尝试在 Cassandra 中查询我的一张表,结果显示查询失败。我试图深入挖掘其背后的原因,发现这是因为墓碑。我将 GC_GRACE_SECONDS 更改为零并使用 nodetool 触发压缩,当我再次查询时它工作正常。但是在随后的呼叫中,查询再次失败,原因相同。我正在使用 cassandra-nodejs 驱动程序。这是我的数据模型。
CREATE TABLE my_table (
firstname text,
lastname text,
email text,
mobile text,
date timeuuid,
value float,
PRIMARY KEY (firstname, lastname, email, mobile)
) WITH CLUSTERING ORDER BY (lastname ASC, email ASC, mobile ASC);
这是我要在该数据模型上执行的查询。
SELECT firstname, email, toDate(date) as date, mobile, value FROM my_table WHERE date >= minTimeuuid('2017-03-25 00:00:00+0000') AND date <= minTimeuuid('2017-03-28 23:59:59+0000') ALLOW FILTERING;
结果将有大约 40k 行。 这表明如果我们删除某些内容,它将被标记为墓碑,并在为给定表设置 GC_GRACE_SECONDS 后被删除。如果我理解正确的话。
- 当我从不删除任何表行时,怎么会出现墓碑问题?
- 当且仅当我们删除一行时,一行将被标记为墓碑是真的吗?
- 清除墓碑,然后有时查询相同的作品,有时却没有,为什么会这样?
- 增加tombstone_failure_threshold值是个好主意吗?(单节点集群应用)
我正在使用 cassandra 3.5,带有 cqlsh 版本 5.0.1。并且查询在终端上运行良好,但是当我们使用外部客户端执行时出错(使用 nodejs 驱动程序的 cassandra 快速应用程序)。我有一个单节点集群应用程序。
编辑 1
这是我在字段中插入的空值的日志(我只插入了名称和时间戳);
activity | timestamp | source | source_elapsed
-------------------------------------------------------------------------------------------------+----------------------------+---------------+----------------
Execute CQL3 query | 2017-03-29 10:28:27.342000 | 172.31.34.179 | 0
Parsing select * FROM testtomb WHERE name = 'Dhaval45'; [SharedPool-Worker-2] | 2017-03-29 10:28:27.342000 | 172.31.34.179 | 64
Preparing statement [SharedPool-Worker-2] | 2017-03-29 10:28:27.342000 | 172.31.34.179 | 101
Executing single-partition query on testtomb [SharedPool-Worker-3] | 2017-03-29 10:28:27.342000 | 172.31.34.179 | 210
Acquiring sstable references [SharedPool-Worker-3] | 2017-03-29 10:28:27.342000 | 172.31.34.179 | 223
Skipped 0/0 non-slice-intersecting sstables, included 0 due to tombstones [SharedPool-Worker-3] | 2017-03-29 10:28:27.342000 | 172.31.34.179 | 243
Merged data from memtables and 0 sstables [SharedPool-Worker-3] | 2017-03-29 10:28:27.342000 | 172.31.34.179 | 288
Read 2 live and 0 tombstone cells [SharedPool-Worker-3] | 2017-03-29 10:28:27.342001 | 172.31.34.179 | 310
Merged data from memtables and 0 sstables [SharedPool-Worker-3] | 2017-03-29 10:28:27.342001 | 172.31.34.179 | 323
Request complete | 2017-03-29 10:28:27.342385 | 172.31.34.179 | 385
这是我查询已执行删除查询的字段时的日志。最初,用户Dhaval15的名字是“aaaa”,然后是单元格 aaa。然后再次对同一用户执行选择查询给了我这个日志。
activity | timestamp | source | source_elapsed
-------------------------------------------------------------------------------------------------+----------------------------+---------------+----------------
Execute CQL3 query | 2017-03-29 10:35:18.581000 | 172.31.34.179 | 0
Parsing select * FROM testtomb WHERE name = 'Dhaval15'; [SharedPool-Worker-1] | 2017-03-29 10:35:18.581000 | 172.31.34.179 | 65
Preparing statement [SharedPool-Worker-1] | 2017-03-29 10:35:18.581000 | 172.31.34.179 | 113
Executing single-partition query on testtomb [SharedPool-Worker-3] | 2017-03-29 10:35:18.581000 | 172.31.34.179 | 223
Acquiring sstable references [SharedPool-Worker-3] | 2017-03-29 10:35:18.581000 | 172.31.34.179 | 235
Skipped 0/0 non-slice-intersecting sstables, included 0 due to tombstones [SharedPool-Worker-3] | 2017-03-29 10:35:18.581000 | 172.31.34.179 | 256
Merged data from memtables and 0 sstables [SharedPool-Worker-3] | 2017-03-29 10:35:18.581001 | 172.31.34.179 | 305
Read 1 live and 1 tombstone cells [SharedPool-Worker-3] | 2017-03-29 10:35:18.581001 | 172.31.34.179 | 338
Merged data from memtables and 0 sstables [SharedPool-Worker-3] | 2017-03-29 10:35:18.581001 | 172.31.34.179 | 351
Request complete | 2017-03-29 10:35:18.581430 | 172.31.34.179 | 430