Uploaded image for project: 'PHP Legacy Driver'
  1. PHP Legacy Driver
  2. PHP-212

Mongo object construction sometimes fails to create the connection, yet returns an object anyways



    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Cannot Reproduce
    • Affects Version/s: 1.1.4
    • Fix Version/s: None
    • Component/s: pecl-mongo
    • Labels:
    • # Replies:
    • Last comment by Customer:


      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'


          Issue Links



              • Votes:
                3 Vote for this issue
                2 Start watching this issue


                • Created:
                  Days since reply:
                  7 years, 16 weeks, 6 days ago
                  Date of 1st Reply: