unexpected error messsage setting slaveOk when connected to secondary

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Replication, Shell
    • None
    • ALL
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      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().

            Assignee:
            Randolph Tan
            Reporter:
            Chris Westin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: