gpt4 book ai didi

php - Cassandra - DataSax PHP 驱动程序 - 超时

转载 作者:搜寻专家 更新时间:2023-10-31 21:51:43 25 4
gpt4 key购买 nike

我在使用 Cassandra 的 DataSax php 驱动程序时遇到超时问题。每当我执行某个命令时,它总是在 10 秒后抛出此异常:

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

我的 php 代码是这样的:

$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();

我在 cassandra.yaml 中的设置是:

# 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

我已经试过了:

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

还有这个:

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

还有这个:

set_time_limit(0)

而且它总是在 10 秒后抛出 TimeoutException。我正在使用 Cassandra 3.6有什么想法吗?

最佳答案

使用 withConnectTimeout(代替 withDefaultTimeout 或与 withDefaultTimeout 一起使用)可能有助于避免 TimeoutException(在我的案例中确实如此)

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

但是,如果您需要这么长的超时时间,则可能存在最终需要解决的潜在问题。

关于php - Cassandra - DataSax PHP 驱动程序 - 超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40726832/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com