Priority: Major - P3
Resolution: Cannot Reproduce
Affects Version/s: 1.1.4
Fix Version/s: None
Last comment by Customer:true
We have noticed that sometimes the Mongo() constructor will return a Mongo object without verifying that the connection is fully instantiated.
Specifically, we point to a system that does not have a mongos running, and so does not have anyone listening on the mongos port (27017), and yet Mongo() returns an object. This leads our code to believe that the mongo connection is fine, but then when we try to make a query across it we get a MongoCursorException:
PHP Fatal error: Uncaught exception 'MongoCursorException' with message 'Operation now in progress'
This behavior is counter-intuitive since we are not changing the "connect" option referenced here:
Hence "connect" defaults to TRUE and the Mongo() constructor should complete the connection prior to returning the Mongo object.
However, we have reproducible evidence that the Mongo() constructor is sometimes returning without completing the connection.
We believe this issue is related to the non-blocking nature of the sockets being created by the mongodb PHP driver, since the MongoCursorException we received when querying on the incomplete Mongo object indicates that an EINPROGRESS errno was received by the socket client in the driver.
It is noteworthy that only some Mongo() objects experience the behavior detailed above. Many Mongo objects fail to be created, throwing the following exception during construction:
Exception: exception 'MongoConnectionException' with message 'connecting to mongos1 failed: Operation now in progress'