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

    XMLWordPrintable

    Details

    • 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:
      None
    • # Replies:
      9
    • Last comment by Customer:
      true

      Description

      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:
      http://www.php.net/manual/en/mongo.construct.php
      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'

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              derick Derick Rethans
              Reporter:
              sjerik Erik Weathers
              Participants:
              Last commenter:
              Alexander Golin
              Votes:
              3 Vote for this issue
              Watchers:
              2 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Days since reply:
                7 years, 48 weeks ago
                Date of 1st Reply: