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

MongoCursorException "Broken Pipe" on first 1-20 connections

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical - P2
    • Resolution: Fixed
    • Affects Version/s: 1.2.6
    • Fix Version/s: 1.2.7
    • Component/s: pecl-mongo
    • Environment:
    • # Replies:
      9
    • Last comment by Customer:
      true

      Description

      Getting MongoCursorException with message "Broken pipe" and code 16 when connecting to sharded environment through local mongos process. The exception only happens 50% of the time for the first 20 MongoCollection->save function calls. After the exception stops occurring, killing mongos and restarting will make the exception occur again.

      The data IS being inserted, the connection IS actually made to the mongos and subsequent mongod server. The exception is just wrong.

      1. The data being saved in the MongoCollection->save call is irrelevant, as long as something, anything, is saved.
      2. The collection itself is irrelevant - it does not have to be sharded or unsharded.
      3. The PHP script has to be run through Apache, not the CLI.
      4. The database and collection MUST be replicated.
      5. 'safe' has to be specified and greater than 1.

      Mongod template command

      sudo mongod --fork --rest --smallfiles --oplogSize 100 --slowms 50 --port 13000 --logpath $LOG_PARENT/a1/mongod.log --dbpath $DATA_PARENT/a1 --replSet a --shardsvr

      Mongos command

      sudo mongos --port 27017 --logpath $LOG_PARENT/mongos1/mongos.log --logappend --fork --configdb localhost:13100,localhost:13101,localhost:13102

      Replication configuration template

      echo "rs.initiate({_id: 'a', members: [\{_id: 0, host: 'localhost:13000', priority: 3\},\{_id: 1, host: 'localhost:13001', priority: 2\},\{_id: 2, host: 'localhost:13002', priority: 1\}]})" | mongo localhost:13000

      Add shard script

      echo "db.runCommand({addshard: 'a/localhost:13000'})" | mongo admin

      PHP Script

      <?php
      $m = new Mongo();
      $m->garbage->garbage->save(array('time' => time()), array('safe' => 2));

      Command Line Calling of the PHP script

      for i in {1..100}
      do
      curl http://localhost/script.php
      done

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

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