Details
Description
I have found that the couchbase4 php extention locks up after a php process has been forked
I have attached a snippet of code to show the lockup.
#!/usr/bin/php
|
<?php
|
include __DIR__ . '/application/cli/environment.php'; // basically composer autoload |
|
use \Couchbase\ClusterOptions;
|
use \Couchbase\Cluster;
|
|
$username = 'username'; |
$password = 'password'; |
$connectionString = 'couchbase://10.10.10.10'; |
|
$clusterOpts = new ClusterOptions(); |
$clusterOpts->credentials($username, $password);
|
|
$couchbase = new Cluster($connectionString, $clusterOpts); |
$bucket = $couchbase->bucket('default'); |
$collection = $bucket->defaultCollection();
|
|
$result = $collection->upsert('test-key', [time(), 'some data']); |
|
$data = $collection->get('test-key')->content(); |
|
print_r($data);
|
|
$processId = pcntl_fork();
|
if ($processId < 0) { |
// cleanup using posix_kill & pcntl_wait |
throw new RuntimeException('pcntl_fork failed.'); |
} elseif ($processId === 0) { |
// WE ARE IN THE CHILD |
$clusterOpts = new ClusterOptions(); |
$clusterOpts->credentials($username, $password);
|
|
$couchbase = new Cluster($connectionString, $clusterOpts); |
$bucket = $couchbase->bucket('default'); |
$collection = $bucket->defaultCollection();
|
|
$data = $collection->get('test-key')->content(); // <-- locks up and never returns |
|
print_r($data);
|
} else { |
// WE ARE IN THE PARENT |
echo "parent\r\n"; |
}
|