SASI Indexes in Cassandra seem to have some bugs

扶醉桌前 提交于 2019-12-13 13:45:25

问题


I just started working with the SASI index on Cassandra 3.7.0 and I encountered a problem which as I suspected was a bug. I had hardly tracked down the situation in which the bug showed up, here is what I found:

When querying with a SASI index, it may incorrectly return 0 rows, and changing a little conditions, it works again, like the following CQL code:

CREATE TABLE IF NOT EXISTS roles (
    name text,
    a int,
    b int,
    PRIMARY KEY ((name, a), b)
) WITH CLUSTERING ORDER BY (b DESC);

insert into roles (name,a,b) values ('Joe',1,1);
insert into roles (name,a,b) values ('Joe',2,2);
insert into roles (name,a,b) values ('Joe',3,3);
insert into roles (name,a,b) values ('Joe',4,4);

CREATE TABLE IF NOT EXISTS roles2 (
    name text,
    a int,
    b int,
    PRIMARY KEY ((name, a), b)
) WITH CLUSTERING ORDER BY (b ASC);

insert into roles2 (name,a,b) values ('Joe',1,1);
insert into roles2 (name,a,b) values ('Joe',2,2);
insert into roles2 (name,a,b) values ('Joe',3,3);
insert into roles2 (name,a,b) values ('Joe',4,4);

CREATE CUSTOM INDEX ON roles (b) USING 'org.apache.cassandra.index.sasi.SASIIndex' 
WITH OPTIONS = { 'mode': 'SPARSE' };
CREATE CUSTOM INDEX ON roles2 (b) USING 'org.apache.cassandra.index.sasi.SASIIndex' 
WITH OPTIONS = { 'mode': 'SPARSE' };

Noticing that I only change table roles2 from table roles's 'CLUSTERING ORDER BY (b DESC)' into 'CLUSTERING ORDER BY (b ASC)'.

When querying with statement select * from roles2 where b<3;, the rusult is two rows:

 name | a | b
------+---+---
  Joe | 1 | 1
  Joe | 2 | 2

(2 rows)

However, if querying with select * from roles where b<3;, it returned no rows at all:

 name | a | b
------+---+---

(0 rows)

This is not the only situation where the bug would show up, one time I created a SASI index with specific name like 'end_idx' on column 'end', the bug showed up, when I didn't specify the index name, it gone.

Please help me confirm this bug, or tell me if I'd used the SASI index the wrong way.

来源:https://stackoverflow.com/questions/38290270/sasi-indexes-in-cassandra-seem-to-have-some-bugs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!