Details
-
Bug
-
Status: Resolved
-
Normal
-
Resolution: Fixed
-
Correctness - API / Semantic Implementation
-
Normal
Description
As a follow up of http://www.mail-archive.com/user@cassandra.apache.org/msg50816.html
Duplicate results appear with secondary index on static column with RF > 1.
Number of results vary depending on consistency level.
Here is a CCM session to reproduce the issue:
romain@debian:~$ ccm create 39 -n 3 -v 3.9 -s Current cluster is now: 39 romain@debian:~$ ccm node1 cqlsh Connected to 39 at 127.0.0.1:9042. [cqlsh 5.0.1 | Cassandra 3.9 | CQL spec 3.4.2 | Native protocol v4] Use HELP for help. cqlsh> CREATE KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 2}; cqlsh> CREATE TABLE test.idx_static (id text, id2 bigint static, added timestamp, source text static, dest text, primary key (id, added)); cqlsh> CREATE index ON test.idx_static (id2); cqlsh> INSERT INTO test.idx_static (id, id2, added, source, dest) values ('id1', 22,'2017-01-28', 'src1', 'dst1'); cqlsh> SELECT * FROM test.idx_static where id2=22; id | added | id2 | source | dest -----+---------------------------------+-----+--------+------ id1 | 2017-01-27 23:00:00.000000+0000 | 22 | src1 | dst1 id1 | 2017-01-27 23:00:00.000000+0000 | 22 | src1 | dst1 (2 rows) cqlsh> CONSISTENCY ALL Consistency level set to ALL. cqlsh> SELECT * FROM test.idx_static where id2=22; id | added | id2 | source | dest -----+---------------------------------+-----+--------+------ id1 | 2017-01-27 23:00:00.000000+0000 | 22 | src1 | dst1 id1 | 2017-01-27 23:00:00.000000+0000 | 22 | src1 | dst1 id1 | 2017-01-27 23:00:00.000000+0000 | 22 | src1 | dst1 (3 rows)
When RF matches the number of nodes, it works as expected.
Example with RF=3 and 3 nodes:
romain@debian:~$ ccm create 39 -n 3 -v 3.9 -s Current cluster is now: 39 romain@debian:~$ ccm node1 cqlsh Connected to 39 at 127.0.0.1:9042. [cqlsh 5.0.1 | Cassandra 3.9 | CQL spec 3.4.2 | Native protocol v4] Use HELP for help. cqlsh> CREATE KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 3}; cqlsh> CREATE TABLE test.idx_static (id text, id2 bigint static, added timestamp, source text static, dest text, primary key (id, added)); cqlsh> CREATE index ON test.idx_static (id2); cqlsh> INSERT INTO test.idx_static (id, id2, added, source, dest) values ('id1', 22,'2017-01-28', 'src1', 'dst1'); cqlsh> SELECT * FROM test.idx_static where id2=22; id | added | id2 | source | dest -----+---------------------------------+-----+--------+------ id1 | 2017-01-27 23:00:00.000000+0000 | 22 | src1 | dst1 (1 rows) cqlsh> CONSISTENCY all Consistency level set to ALL. cqlsh> SELECT * FROM test.idx_static where id2=22; id | added | id2 | source | dest -----+---------------------------------+-----+--------+------ id1 | 2017-01-27 23:00:00.000000+0000 | 22 | src1 | dst1 (1 rows)
Example with RF = 2 and 2 nodes:
romain@debian:~$ ccm create 39 -n 2 -v 3.9 -s Current cluster is now: 39 romain@debian:~$ ccm node1 cqlsh Connected to 39 at 127.0.0.1:9042. [cqlsh 5.0.1 | Cassandra 3.9 | CQL spec 3.4.2 | Native protocol v4] Use HELP for help. cqlsh> CREATE KEYSPACE test WITH replication = {'class': 'SimpleStrategy', 'replication_factor': 2}; cqlsh> CREATE TABLE test.idx_static (id text, id2 bigint static, added timestamp, source text static, dest text, primary key (id, added)); cqlsh> INSERT INTO test.idx_static (id, id2, added, source, dest) values ('id1', 22,'2017-01-28', 'src1', 'dst1'); cqlsh> CREATE index ON test.idx_static (id2); cqlsh> INSERT INTO test.idx_static (id, id2, added, source, dest) values ('id1', 22,'2017-01-28', 'src1', 'dst1'); cqlsh> SELECT * FROM test.idx_static where id2=22; id | added | id2 | source | dest -----+---------------------------------+-----+--------+------ id1 | 2017-01-27 23:00:00.000000+0000 | 22 | src1 | dst1 (1 rows) cqlsh> CONSISTENCY ALL Consistency level set to ALL. cqlsh> SELECT * FROM test.idx_static where id2=22; id | added | id2 | source | dest -----+---------------------------------+-----+--------+------ id1 | 2017-01-27 23:00:00.000000+0000 | 22 | src1 | dst1 (1 rows)