【问题标题】:Cassandra PHP Driver hangsCassandra PHP 驱动程序挂起
【发布时间】:2020-07-18 04:37:45
【问题描述】:

当通过 cluster->connect() 连接到集群时,PHP 脚本挂起。

虽然我用 nodejs 驱动程序尝试这个

const cassandra = require('cassandra-driver');
const client = new cassandra.Client({
contactPoints: ['127.0.0.1'],
localDataCenter: 'datacenter1',
keyspace: 'test'
});
const query = 'SELECT * FROM mytable';
client.execute(query).then(console.log).catch( console.log );

我们得到以下输出

ResultSet {
info: {
queriedHost: '127.0.0.1:9042',
triedHosts: { '127.0.0.1:9042': null },
speculativeExecutions: 0,
achievedConsistency: 10,
traceId: undefined,
warnings: undefined,
customPayload: undefined,
isSchemaInAgreement: true
},
rows: [ Row { id: 'test' } ],
rowLength: 1,
columns: [ { name: 'id', type: [Object] } ],
pageState: null,
nextPage: undefined,
nextPageAsync: undefined
}

当我们使用 PHP 执行此操作时,它会挂起

<?php
$cluster   = \Cassandra::cluster()
->withContactPoints( '127.0.0.1' )
->withPort( 9042 )
->build();
// This will happen immediately
// var_dump( 'Built!' );exit;
$session   = $cluster->connect( 'test' );
// This hangs. It never dumps 'Connected!'.
var_dump( 'Connected!' );exit;
var_dump( $session->execute( new \Cassandra\SimpleStatement( 'select * from mytable' ), array() ) );

下面附上所需的文件

index.php -> https://pastebin.com/iihpJfpW

Vagrantfile -> https://pastebin.com/BkPwynxy

cassandra.repo -> https://pastebin.com/LbraCY3f

index.js -> https://pastebin.com/TSPc0bLm

  1. 新建文件夹“cassandraTest”
  2. 将 Vagrantfile 放入文件夹中
  3. 在“cassandraTest”中创建名为“provision”的新目录
  4. 把 cassandra.repo 放在那里
  5. 流浪

注意

这不是 Vagrant 问题,因为在我们运行 CentOS 7.6 的 Stage 环境中也会出现同样的问题

环境:

CentOS 7.6

卡桑德拉 3.11.6 原生协议 v4

NodeJs 12 NodeJs Cassandra 驱动程序 4.5.0

PHP 7.2 PHP Cassandra 驱动程序(最新,通过 yum install -y php72-php-pecl-cassandra.x86_64 from remi 安装)

流浪者 2.2.7 Oracle VirtualBox 版本 6.1.4 r136177 (Qt5.6.2)

【问题讨论】:

  • 您使用的是哪个版本的cassandra-cpp-driver?这可能是在最新版本中修复的bug
  • 你有什么解决办法吗?我经常遇到这个问题/我只能通过降级或升级到特定版本的 libuv、cassandra-cpp-driver 和 cassandra 来解决它。我在 debian 9 和 debian 10 上使用 php-7.4 /(我第一次遇到 php7.2 的问题)
  • 你能提供你的 cassandra.so 的 ld (/usr/bin/ld) 吗?

标签: php cassandra cassandra-php-driver


【解决方案1】:

查看您询问的日期和症状,我认为您正在点击bug

尝试将cassandra-cpp-driver 升级到 v2.15.2,看看是否有效。

【讨论】:

  • 不适合我,我已经尝试过从 2.15.0 到 2.15.3 的版本,即使我更改了 libuv 版本。我认为问题在于为 php 编译的 cassandra.so 周围的动态依赖关系。调查正在进行中。当我对 cassandra.so 进行 ld 时,我有很多未定义的参考
猜你喜欢
  • 2016-02-27
  • 1970-01-01
  • 2016-05-18
  • 2017-04-05
  • 2014-04-24
  • 2017-11-15
  • 2017-06-23
  • 2016-10-03
  • 2017-01-13
相关资源
最近更新 更多