in the forks I am doing a completely new connection to the Couchbase, and the connection works. Seems that the getMulti doesn’t work
LATER EDIT:
I tried also with a normal get or query and doesn’t work. it just remains hung (On a standard query I don’t see the above error anymore, but still doesn’t return anyting)
@flaviu do you happen to know if your application server is pegged up with CPU ? how many threads are you spawning ? Can you share your code (replace any credentials / ip addresses)
use Couchbase\Cluster;
use Couchbase\ClusterOptions;
use Couchbase\QueryOptions;
require __DIR__ . '/../always-include-top.php';
// $connectionString = "couchbase://server";
// $options = new ClusterOptions();
//
// $options->credentials("Administrator", "password");
// $cluster = new Cluster($connectionString, $options);
// $options = new QueryOptions();
//
// $query = "
// SELECT RAW
// meta().id AS id
// FROM
// `table`
// WHERE
// meta().id > 'document_id'
// ORDER BY
// meta().id
// LIMIT 3
// ";
//
// $charts = $cluster->query($query, $options)->rows();
$childPid = pcntl_fork();
if ($childPid === - 1) {
}
else if ($childPid === 0) {
// Child code
try {
$connectionString1 = "couchbase://server";
$options1 = new ClusterOptions();
$options1->credentials("Administrator", "password");
$cluster1 = new Cluster($connectionString1, $options1);
$bucket = $cluster1->bucket("top-charts");
$collection = $bucket->defaultCollection();
//here can be any type of DB query not just a getMulti
$results = $collection->getMulti( array("document1","document2","document3"));
}
catch (Throwable $e) {
exit(255);
}
finally {
exit(0);
}
}
else {
// Base cronjob code
$arrJobsStarted[] = $childPid;
}
If I execut the Couchbase connection before the fork the connection inside the spawned process is not executed anymore. If I comment that out the spawned process works correctly. The problem is that I need Couchbase connection inside the spawned process and outside. And as you can see the in spawned process, I do a completely new DB connection
The alternative solution that I am using right now is that instead of spawning a new connection, am using exec with some arguments