Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cassandra - DataSax PHP Driver - Timeout

Tags:

php

cassandra

I'm having problems with timeout using the DataSax php driver for Cassandra. Whenever I execute a certain command it always throws this exception after 10s:

PHP Fatal error:  Uncaught exception 'Cassandra\Exception\TimeoutException' with message 'Request timed out'

My php code is like this:

$cluster   = Cassandra::cluster()->build();
$session   = $cluster->connect("my_base");
$statement = new Cassandra\SimpleStatement("SELECT COUNT(*) as c FROM my_table WHERE my_colunm = 1 AND my_colunm2 >= '2015-01-01' ALLOW FILTERING")
$result    = $session->execute($statement);
$row = $result->first();

My settings in cassandra.yaml is:

# How long the coordinator should wait for read operations to complete
read_request_timeout_in_ms: 500000
# How long the coordinator should wait for seq or index scans to complete
range_request_timeout_in_ms: 1000000
# How long the coordinator should wait for writes to complete
write_request_timeout_in_ms: 2000
# How long the coordinator should wait for counter writes to complete
counter_write_request_timeout_in_ms: 50000
# How long a coordinator should continue to retry a CAS operation
# that contends with other proposals for the same row
cas_contention_timeout_in_ms: 50000
# How long the coordinator should wait for truncates to complete
# (This can be much longer, because unless auto_snapshot is disabled
# we need to flush first so we can snapshot before removing the data.)
truncate_request_timeout_in_ms: 60000
# The default timeout for other, miscellaneous operations
request_timeout_in_ms: 1000000

I've already tried this:

$result    = $session->execute($statement,new Cassandra\ExecutionOptions([
        'timeout' => 120
    ])
);

and this:

$cluster   = Cassandra::cluster()->withDefaultTimeout(120)->build();

and this:

set_time_limit(0)

And it always throws the TimeoutException after 10s.. I'm using Cassandra 3.6 Any idea?

like image 408
giordanolima Avatar asked Jan 17 '26 04:01

giordanolima


1 Answers

Using withConnectTimeout (instead of, or together with withDefaultTimeout) might help avoid a TimeoutException (it did in my case)

$cluster = Cassandra::cluster()->withConnectTimeout(60)->build();

However, if you need such a long timeout, then there is probably an underlying problem that will need solving eventually.

like image 198
towr Avatar answered Jan 19 '26 17:01

towr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!