首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Cassandra datastax | TimeoutException

Cassandra datastax | TimeoutException
EN

Stack Overflow用户
提问于 2019-02-28 17:46:55
回答 3查看 384关注 0票数 0

我对cassandra有一个问题,我有以下错误。我链接一张图片

代码语法:

代码语言:javascript
复制
 public function find($db_table = null, $db_id = null) {
        $filter = "";
        $return = array();

        $cluster = $this->cluster();
        $session = $cluster->connect($this->keyspace);

        if(isset($db_table)) {
            $filter .= " WHERE db_table like '%".$db_table."%' ";

            if($db_id != null) {
                $filter .= " AND db_id = '".$db_id."' ALLOW FILTERING";
            }
        }

        $query  = new Cassandra\SimpleStatement("SELECT * FROM ".$this->keyspace.".log $filter;");
        $result = $session->executeAsync($query);
        $rows   = $result->get();

Cassandra Error picture

EN

回答 3

Stack Overflow用户

发布于 2019-02-28 21:38:10

  1. 除非您知道自己在做什么,否则不应使用"allow filtering“。
  2. SELECT* FROM prod.log WHERE db_id = 13913 db_table LIKE '%%‘product LIMIT 5000即将超时,因为您在数据库中似乎有很多条目,并且allow filtering正在执行全表扫描。
    1. 您应该调整表设计以匹配查询。
票数 1
EN

Stack Overflow用户

发布于 2019-02-28 21:38:43

更多细节可以在这里找到。

https://docs.datastax.com/en/developer/php-driver/1.2/api/Cassandra/Cluster/class.Builder/

使用withConnectTimeout可能有助于避免TimeoutException

代码语言:javascript
复制
$cluster = $this->cluster()->withConnectTimeout(60);

您可以通过更改/etc/cassandra/cassandra.yaml中的值来增加超时值

类似于下图--

sudo nano /etc/cassandra/cassandra.yaml (用于编辑cassandra.yaml文件)

代码语言:javascript
复制
# How long the coordinator should wait for read operations to complete
read_request_timeout_in_ms: 50000
# How long the coordinator should wait for seq or index scans to complete
range_request_timeout_in_ms: 100000
# How long the coordinator should wait for writes to complete
write_request_timeout_in_ms: 20000
# 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: 10000
# 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: 600000
# The default timeout for other, miscellaneous operations
request_timeout_in_ms: 100000

# How long before a node logs slow queries. Select queries that take longer than
# this timeout to execute, will generate an aggregated log message, so that slow queries
# can be identified. Set this value to zero to disable slow query logging.
slow_query_log_timeout_in_ms: 5000
票数 0
EN

Stack Overflow用户

发布于 2019-05-30 09:42:51

  1. 在cassandra上使用"LIKE“我不这么认为:(
  2. your query :(尝试做一些更干净的事情,而不是使用".$db_table.”进行正确的绑定使用。?然后在你的exec(

,‘

  1. ’)值中,你的意思是什么?with SELECT * FROM“.$.log->keyspace.”这不是一个查询!如果你在php中使用这个,语法肯定是完全错误的。您编写了SELECT * FROM keyspace_name.log WHERE table like‘WHERE’和id = 'something‘:(更糟糕的是,select ALL

这永远不会发生

  • 你使用$this从哪里调用你的集群?这是从哪里来的?

好的,我可以列举10个不同的原因来解释你的代码不工作,但这不是我的目标,我想要帮助你,所以试着做一些简单的事情。

____ good_____

代码语言:javascript
复制
<?

$cluster   = Cassandra::cluster()
               ->withContactPoints('127.0.0.1')
               ->build();
$session   = $cluster->connect("your_k_space");


$table_list = $session->execute("SELECT table_name FROM system_schema.tables WHERE keyspace_name = 'your_k_space'");


if (in_array($db_table, $table_list)) {
   $options = array('arguments' => [$db_table,$db_id]);
    $result = $session->execute("SELECT * FROM ? WHERE db_id = ?  ALLOW FILTERING",$options);
    foreach ($result as $key => $value) print_r($value);



}else{
    die('table not found');
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54922648

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档