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

MongoCursor::slaveOkay() has no effect in 1.3.2

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical - P2
    • Resolution: Fixed
    • Affects Version/s: 1.3.1
    • Fix Version/s: 1.3.3
    • Component/s: pecl-mongo
    • Labels:
      None
    • Environment:
      Tested on OS X 10.8, PHP 5.4.7 cli
    • # Replies:
      4
    • Last comment by Customer:
      true

      Description

      Since the new connection handling / MongoClient introduction there is no way to set if a query should run on a secondary per cursor (request), however the documentation does not mention this. In http:://php.net/manual/en/mongocursor.slaveokay.php it explicitly states that reads would go to secondaries, if conditions are met. Either the documentation should mention this or this should be fixed (unlikely, right?).

      This prevents us from upgrading past 1.2.x, since we use this extensively. By default we have all finds go to the primary and then specify which finds should go to secondaries when constructing the query.

      Here is a test I used:

      <?php
       
      $conn = new MongoClient('mongodb://mongo-data-prim,mongo-data-sec1,mongo-data-sec2', array(
      	'replicaSet' => 'myset',
      ));
       
      $col = $conn->test->members;
       
      MongoCursor::$slaveOkay = true;
      $cursor = $col->find(array(), array('email' => true));
      $cursor->slaveOkay(true)->limit(1);
       
      print_r(iterator_to_array($cursor));
      print_r($cursor->info()); // always contains IP of mongo-data-prim
      ?>

        Attachments

          Issue Links

            Activity

              People

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

                Dates

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