-
Notifications
You must be signed in to change notification settings - Fork 263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A never-ending query after upgrade to MongoDB 6.0.3 #1048
Comments
Looking at the trace you provided, I can see a legacy hello being sent to the server, but I can't see a response received from the server. This indicates that while the driver was able to establish a connection to the server (ruling out SSL issues etc.), the handshake does not complete successfully. However, I'm not sure what exactly is causing this. As an alternative to strace, could you please try to run the small One more thing, did you try downgrading to an older MongoDB version? I've been running 6.0.3 without having this issue, and it surprises me that it would hang like this when other tools connect just fine. Figuring out whether it happens only on 6.0.3 or on older versions as well would help us in trying to locate the source of the problem. |
Thanks for your help.
Custom error log remains empty as well as /var/log/php/php-errors.log |
That is odd. Running the code as above should definitely produce some output. Here is an example from my machine:
Even without running a command there should be some output, as instantiating a |
FInally I sorted it out. It doesn't connect when the connection string is for cluster, I mean it looks like this:
But it's ok when I connect to a single server of a cluster:
I created a repo https://github.com/pavelsc/mongodb-php-test to reproduce. It consists of two docker containers: mongo-db and mongo-php-app. mongo-php-app connects to a mongo-db single instance by default and works correctly. If you have a mongo cluster you can change config
then build mongo-php-app and run |
I cloned https://github.com/pavelsc/mongodb-php-test to attempt reproduction. I extracted I started both containers with
I then created an Atlas M0 cluster (server version 6.0.5) and obtained the non-SRV connection string so I could enter each of the three hosts and replica set name in the @@ -1,11 +1,13 @@
<?php
return [
- "username" => "root",
- "password" => "example",
+ "username" => "<username>",
+ "password" => "<password>",
"database" => "dev",
- "replica_set" => "",
+ "replica_set" => 'atlas-r3glsi-shard-0',
"host" => [
- "mongo-db:27017"
+ 'ac-tkwmcmr-shard-00-00.07pgo2r.mongodb.net:27017',
+ 'ac-tkwmcmr-shard-00-01.07pgo2r.mongodb.net:27017',
+ 'ac-tkwmcmr-shard-00-02.07pgo2r.mongodb.net:27017',
]
]; I then modified @@ -62,11 +62,12 @@ class MongoHelper
}
try {
- $connStr = "mongodb://{$mongoDbAuth}{$host}/?{$replicaSet}";
+ $connStr = "mongodb://{$mongoDbAuth}{$host}/?ssl=true&{$replicaSet}";
echo $connStr . "\r\n";
$client = new Client($connStr);
$this->contactsDb = $client->{$this->database};
$this->contactsCollection = $this->contactsDb->{$this->contactsCollectionName};
+ var_dump($client->admin->command(['ping' => 1])->toArray()[0]);
} catch (Exception $e) {
echo $e->getMessage();
exit(); After modifying both files, I rebuilt the containers using
The script had no trouble connecting to and pinging the Atlas M0 cluster. |
@jmikola wow, thanks, that was unexpected. Seems I gotta check my cluster setup |
Bug Report
Hello, I have an issue with execution of a simple findOne query which worked correctly before mongodb upgrade to 6.0.3. There are no errors when the script is executed, it just stays in a running state with no response after a successfull connection. Error reporting is set to E_ALL. Compass app shows tables and data without delays.
Query is a quite simple
Also I tried to ping MongoDB:
strace -tt php -r '$m = new MongoDB\Driver\Manager( "mongodb://10.60.75.73:27017,10.60.75.74:27017,10.60.75.75:27017/?replicaSet=rs0" ); var_dump($m->executeCommand( "admin", new MongoDB\Driver\Command( [ "ping" => 1] ) ) );'
Pastebin
Environment
I use PHP 8.1.14 (cli) (built: Jan 4 2023 06:45:14) (NTS gcc x86_64)
with mongodb/mongodb 1.15.0
MongoDB version 6.0.3
I tried it from scratch with Docker configuration listed below with the same result:
The text was updated successfully, but these errors were encountered: