RPC timeout in cqlsh - Cassandra

2019-01-26 06:23发布

问题:

I have 5 nodes in my ring with SimpleTopologyStrategy and replication_factor=3. I inserted 1M rows using stress tool . When am trying to read the row count in cqlsh using

SELECT  count(*) FROM  Keyspace1.Standard1 limit 1000000;

It fails with error:

Request did not complete within rpc_timeout.

It fetches for limit 100000. Fails even for 500000.
All my nodes are up. Do I need to increase the rpc_timeout?

Please help.

回答1:

You get this error because the request is timing out on the server side. One should know that this is a very expensive operation in Cassandra as others have pointed out.

Still, if you really want to do this you should update your /etc/cassandra/cassandra.yaml file and change the range_request_timeout_in_ms parameter. This will be valid for all your range queries.

Example to set a 40 second timeout:

range_request_timeout_in_ms: 40000

You will probably have to adjust at the client side as well. When using cqlsh as a client this is accomplished by creating/updating your configuration file for cqlsh under ~/.cassandra/cqlshrc and add the client_timeout parameter to the connection section.

Example to set a 40 second timeout:

[connection]
client_timeout=40


回答2:

It takes a long time to read in 1M rows so that is probably why it is timing out. You shouldn't use count like this, it is very expensive since it has to read all the data. Use Cassandra counters if you need to count lots of items.

You should also check your Cassandra logs to confirm there aren't any other issues - sometimes exceptions in Cassandra lead to timeouts on the client.



回答3:

If you can live with an approximate row count, take a look at this answer to Row count of a column family in Cassandra.