Atul Dambalkar
Atul Dambalkar

Reputation: 111

Cassandra - cqlsh returns inconsistent results even if CONSISTENCY LEVEL set to ALL or QUORUM

I have a Cassandra cluster with 4 nodes. I have a keyspace with replication factor 3.

Here are the sample cqlsh results I get when I do "select count(*) on a particular table. The results are consistently different even if consistency level is set as ALL or QUORUM.


cqlsh:test> CONSISTENCY all

Consistency level set to ALL.

cqlsh:test> select count(*) from article;

count

28620 (1 rows)

cqlsh:test> select count(*) from article;

count

28703 (1 rows)

cqlsh:test> select count(*) from article;

count

28046 (1 rows)

cqlsh:test> CONSISTENCY QUORUM

Consistency level set to QUORUM.

cqlsh:test> select count(*) from article;

count

28612 (1 rows)

cqlsh:test> select count(*) from article;

count

28122 (1 rows)

cqlsh:test>


Upvotes: 4

Views: 1505

Answers (2)

Jim Meyer
Jim Meyer

Reputation: 9475

I think this is a bug that may have been fixed in release 2.1.6.

See this ticket:

CASSANDRA-8940

Are you using an earlier release than 2.1.6?

Upvotes: 3

Robert Wadowski
Robert Wadowski

Reputation: 1427

Well actually I think that may be cqlsh way of work. From http://docs.datastax.com/en/cql/3.1/cql/cql_reference/select_r.html

SELECT COUNT(*) FROM big_table LIMIT 50000;
SELECT COUNT(*) FROM big_table LIMIT 200000;

The output of these statements if you had 105,291 rows in the database would be: 50000, and 105,291. The cqlsh shell has a default row limit of 10,000. The Cassandra server and native protocol do not limit the number of rows that can be returned, although a timeout stops running queries to protect against running malformed queries that would cause system instability.

Try cqlsh:test> select count(*) from article LIMIT 200000; or another large value

Upvotes: 1

Related Questions