Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/jpa/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/joomla/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Cassandra Dse\Exception\RuntimeException:所有I/O线程上的所有连接都很忙_Cassandra_Datastax Enterprise_Datastax Startup_Datastax Php Driver - Fatal编程技术网

Cassandra Dse\Exception\RuntimeException:所有I/O线程上的所有连接都很忙

Cassandra Dse\Exception\RuntimeException:所有I/O线程上的所有连接都很忙,cassandra,datastax-enterprise,datastax-startup,datastax-php-driver,Cassandra,Datastax Enterprise,Datastax Startup,Datastax Php Driver,我们的web应用程序中有一个删除大量数据的工具。为此,我们将根据u\u id找到的所有记录分页 我们的键是为应用程序中的其他查询而设计的-理想情况下,为u\u id提供主键会很好,但这会破坏所有其他查询 以下方法在大多数情况下运行良好,但是,在删除大约600-800万条记录后,我们得到: Dse\Exception\RuntimeException:所有I/O线程上的所有连接都很忙 我们有时也会收到一条稍有不同的错误消息: Dse\Exception\ReadTimeoutException:操

我们的web应用程序中有一个删除大量数据的工具。为此,我们将根据
u\u id
找到的所有记录分页

我们的键是为应用程序中的其他查询而设计的-理想情况下,为
u\u id
提供主键会很好,但这会破坏所有其他查询

以下方法在大多数情况下运行良好,但是,在删除大约600-800万条记录后,我们得到:

Dse\Exception\RuntimeException:所有I/O线程上的所有连接都很忙

我们有时也会收到一条稍有不同的错误消息:

Dse\Exception\ReadTimeoutException:操作超时-仅收到0个响应

您将在下面的代码中注意到usleep(2500000)暂停脚本。这是我们的解决方法,但最好能解决这个问题,因为Cassandra应该能够处理这个数量的删除

$cluster        = \Dse::cluster()
                    ->withDefaultTimeout(3600)
                      ->withContactPoints(env('CA_HOST'))
                        ->build();

$session        = $cluster->connect(env('CONNECT'));
$options        = array('page_size' => 50);
$results        = $session->execute("SELECT * FROM datastore WHERE u_id = $u_id;", $options);
$future_deletes = array();

while (true) {

    foreach ($results as $result) {

      $future_deletes[] = $session->executeAsync("DELETE FROM datastore WHERE record_id = '" . $result['record_id'] . "' AND record_version = " . $result['record_version'] . " AND user_id = " . $result['user_id']);
      $future_deletes[] = $session->executeAsync("UPDATE data_count set u_count = u_count - 1 WHERE u_id = " . $u_id);

    }

    if( !empty($future_deletes) ){
      foreach ($future_deletes as $future_delete) {
          // we will not wait for each result for more than 5 seconds
          $future_delete->get(5);
      }
      //usleep(2500000); //2.5 seconds
    }

    $future_deletes = array();

    if ($results->isLastPage()) {
        break;
    }

    $results = $results->nextPage();

}

//Disconnect
$session = NULL;
以下是我们的表格供您参考:

CREATE TABLE datastore (id uuid,
    record_id varchar,
    record_version int,
    user_id int,
    u_id int,
    column_1 varchar,
    column_2 varchar,
    column_3 varchar,
    column_4 varchar,
    column_5 varchar,
PRIMARY KEY((record_id), record_version, user_id)
);
CREATE INDEX u_id ON datastore (u_id);

CREATE TABLE data_count (u_id int PRIMARY KEY, u_count counter);
我们正在运行一个8GB内存的服务器

DSE驱动程序的版本为6.0.1


提前谢谢你

您需要控制,在同一时间点,您有多少“飞行中”请求。每个连接的查询数和连接数都有限制。它们是由集群类的相应函数控制的(在PHP文档中找不到足够快的,但是它应该类似于PHP是C++驱动程序之上的)。谢谢您的帮助@亚历克斯。我正在努力在PHP文档()中找到一个等价物,也许我找错地方了?我们还查看了
cassandra.yaml
,它们似乎被设置为默认值,即“无限”。最后,从我最初的消息开始,我们还尝试使用
netstat-tapn | grep php | grep 9042 | wc-l
查看netstat,其中显示的连接数为22,在另一个测试中显示的连接数为23。这不是Cassandra参数,而是驱动程序。您需要使用connectionsperhost函数查看函数
,与IoThreads一起使用
withIOThreads
…谢谢@alex-我昨天查到了这一点,似乎已经解决了我们的问题。我已经做了很多大型测试来确认。谢谢你的帮助