1

NOTE: I am having more than 15967908 records. I am a newbie to Cassandra. Reference: Is there a way to effectively count rows of a very huge partition in Cassandra?

Coordinator node timed out waiting for replica nodes in Cassandra Datastax while insert data

Hi pals, I search for other answers but it didn't work out for me. They had mentioned that we need to increase the time out in cassandra.yaml file but the problem is I don't have the file.

I have installed the Cassandra with HomeBrew. Following is the version that I am currently running on my MacBook

cqlsh:cassandra_training> show version;
[cqlsh 5.0.1 | Cassandra 3.11.4 | CQL spec 3.4.4 | Native protocol v4]

When I do

cqlsh:cassandra_training> select count(*) from access_point_logs;

Then getting the following error

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

Which file I need to increase the timeout. As I am not getting the cassandra.yaml file.

My Cassandra installation path is as follows

/usr/local/Cellar/cassandra/3.11.4

Is there any way to count the number of records.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Channaveer Hakari
  • 2,769
  • 3
  • 34
  • 45

2 Answers2

1

In short, the answer is no. You shouldn't be running queries without specifying any keys as it is not how Cassandra was designed.

If you just need a one off number, you can use nodetool tablestats to do so.

nodetool tablestats cassandra_training.access_point_logs

Look for "Number of keys (estimate)" in the output.

The above command will give you an estimated number of partition keys in your table, so this may or may not be what you are looking for.

If you need to get this number on a regular basis I would normally create another table of counters and manage it when you add/remove records from another table.

Jim Wright
  • 5,905
  • 1
  • 15
  • 34
0

I sorted out the issue. While creating the table I was not properly adding the Primary Key with Cluster Key because of which it was showing this kind of error.

Earlier I had created a table structure in the following way

create table access_point_logs (
    id bigint primary key,
    wd_number varchar,
    ip_address varchar,
    mac_address varchar,
    created_at timestamp,
    updated_at timestamp,
    access_point_id bigint
);

Now changed it to the following

create table access_point_logs(
    id bigint,
    wd_number varchar,
    ip_address varchar,
    mac_address varchar,
    created_at timestamp,
    updated_at timestamp,
    access_point_id bigint,
    primary key ((wd_number), created_at, mac_address)
) with clustering order by (created_at desc);

Just in case if any newbie like me I would like to add the following definition and examples to understand what Partition Key and what Cluster Key is

Carefully observe the change with the following

primary key ((wd_number), created_at, mac_address);


Partition Key - wd_number

Cluster Key - created_at, mac_address

Partition Key - Which particular node to store the data in the Cluster.

Clustering Key - Mainly used for sorting the data and how to display default order while fetching the data.

Primary Key - Maybe a combination of Partition Key + Cluster Key or just a Partition Key

Hope it may help someone. In case if anyone has queries please feel free to fire. I will do my best to answer those.

Channaveer Hakari
  • 2,769
  • 3
  • 34
  • 45