Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-3816

unexpected error messsage setting slaveOk when connected to secondary

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • None
    • Replication, Shell
    • None
    • ALL

    Description

      rs.slaveOk() can generate a spurious error message depending on the order it is used in the shell when connected to a secondary.

      If you remember to set slaveOk first, all is well:

      $ ./mongo --port 27018
      MongoDB shell version: 2.1.0-pre-
      connecting to: 127.0.0.1:27018/test
      SECONDARY> use training
      switched to db training
      SECONDARY> rs.slaveOk();
      SECONDARY> db.scores.findOne();
      {
      "_id" : ObjectId("4c90f2543d937c033f424701"),
      "student" : 0,
      "name" : "quiz",
      "score" : 50
      }
      SECONDARY>

      But if you don't, you get this:

      MongoDB shell version: 2.1.0-pre-
      connecting to: 127.0.0.1:27018/test
      SECONDARY> use training
      switched to db training
      SECONDARY> db.scores.findOne();
      Mon Sep 12 12:20:03 uncaught exception: error

      { "$err" : "not master and slaveok =false", "code" : 13435 }

      SECONDARY> rs.slaveOk();
      not master and slaveok=false
      SECONDARY> db.scores.findOne();
      {
      "_id" : ObjectId("4c90f2543d937c033f424701"),
      "student" : 0,
      "name" : "quiz",
      "score" : 50
      }
      SECONDARY> exit
      bye

      Note the extra "not master and slaveok=false" that comes out after the rs.slaveOk().

      Attachments

        Activity

          People

            randolph@mongodb.com Randolph Tan
            cwestin Chris Westin
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: