priyanka Dhiman
priyanka Dhiman

Reputation: 95

Coordinator node timed out on Cassandra cqlsh shell

I am new to cassandra and trying to do multi node setup on two Mac machine. Its not a datastax casandra. like my Ip is 10.100.1.12 and other machine ip is 10.100.1.15. I have changed the following properties in cassandra.yaml files on bothe the machine:

10.100.1.15:

10.100.1.12:

but when i am trying to retrieve the count of tables its showing me the error:

ReadTimeout: Error from server: code=1200 [Coordinator node timed out waiting for replica nodes' responses] message="Operation timed out - received only 0 responses." info={'received_responses': 0, 'required_responses': 1, 'consistency': 'ONE'}

i tried changing the read_request_timeout_in_ms proprtty from 5000 to 20000 but still i am getting the same error. Could anyone please help what i am doing wrong?

the table schema is following:

cqlsh:app_auditor> describe table traffic_data;

CREATE TABLE app_auditor.traffic_data (
    current_time bigint PRIMARY KEY,
    appid bigint,
    attributes map<text, text>,
    device bigint,
    flow_type text,
    message_time bigint
) WITH bloom_filter_fp_chance = 0.01
    AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'}
    AND comment = ''
    AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'}
    AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'}
    AND crc_check_chance = 1.0
    AND dclocal_read_repair_chance = 0.1
    AND default_time_to_live = 0
    AND gc_grace_seconds = 86400
    AND max_index_interval = 2048
    AND memtable_flush_period_in_ms = 0
    AND min_index_interval = 128
    AND read_repair_chance = 0.0
    AND speculative_retry = '99PERCENTILE';

the count query i am using is select count(*) from traffic_data;

Upvotes: 3

Views: 5453

Answers (1)

Ashraful Islam
Ashraful Islam

Reputation: 12830

In Cassandra count(*) is very costly, cassandra needs to scan all the row from all the node just to give you the count, that's why it's giving you timeout exception.

Instead of using count(*) maintain a counter table, like the below one :

CREATE TABLE traffic_counter (
    type int PRIMARY KEY,
    traffic_count counter
);

When a data insert into traffic_data data, increment the value of traffic_count

UPDATE traffic_counter SET traffic_count = traffic_count + 1 WHERE type = 0;

Now you can select traffic count very efficiently.

SELECT traffic_count FROM traffic_counter WHERE type = 0;

Upvotes: 3

Related Questions