[SERVER-3816] unexpected error messsage setting slaveOk when connected to secondary Created: 12/Sep/11  Updated: 29/Feb/12  Resolved: 01/Feb/12

Status: Closed
Project: Core Server
Component/s: Replication, Shell
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Chris Westin Assignee: Randolph Tan
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-1401 Dont call getLastError if last statem... Closed
Operating System: ALL
Participants:

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



 Comments   
Comment by Randolph Tan [ 01/Feb/12 ]

This bug is not reproducible in master but reproducible in stable release v2.0.2

The bug is caused by the shellPrintHelper calling getLastError and printing the message whenever undefined is passed to it. So this bug can actually be reproduced by simply typing undefined in the terminal right after the find() error.

dup of SERVER-1401

Comment by Eliot Horowitz (Inactive) [ 31/Jan/12 ]

If rs.slaveOk() returned "OK" it would not print this.

Generated at Thu Feb 08 03:04:08 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.