[SERVER-2411] Mongo shell doesn't allow to set slaveOk when connecting to mongos Created: 26/Jan/11  Updated: 12/Jul/16  Resolved: 01/Feb/11

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: 1.7.5
Fix Version/s: 1.7.6

Type: Bug Priority: Minor - P4
Reporter: Aristarkh Zagorodnikov Assignee: Eliot Horowitz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Participants:

 Description   

celestine-3:27017 is a working mongos instance

1.6.5 mongo works fine:
xm@celestine-3:~$ /opt/mongodb/bin/mongo celestine-3
MongoDB shell version: 1.6.5
connecting to: celestine-3
> rs.slaveOk()
>

Current (yesterday 'nightly') behaves strangely
xm@celestine-3:~$ ./db/bin/mongo celestine-3
MongoDB shell version: 1.7.5-pre-
connecting to: celestine-3
> rs.slaveOk()
unrecognized command: replSetGetStatus
>

Connecting to mongod works fine.



 Comments   
Comment by Eliot Horowitz (Inactive) [ 02/Feb/11 ]

Ok, fixed for real

Comment by auto [ 02/Feb/11 ]

Author:

{u'login': u'erh', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: fix replSetGetStatus for shell SERVER-2411
https://github.com/mongodb/mongo/commit/9297201b7f10690812917a60bc6f283e67972625

Comment by Aristarkh Zagorodnikov [ 02/Feb/11 ]

The error changed, but shell still behaves strangely when connected to mongos:

> var f = 0;
replSetGetStatus is not supported through mongos

I suppose the problem lies in shell/dbshell.cpp, sayReplSetMemberState(). It is used as a part of a shell prompt generation and calls replSetGetStatus to find out the replica set name and primary/secondary status. I don't think that shell should call replSetGetStatus on any server at all, unless it's sure that it's connected to a replica set.

Comment by auto [ 01/Feb/11 ]

Author:

{u'login': u'erh', u'name': u'Eliot Horowitz', u'email': u'eliot@10gen.com'}

Message: implement replSetGetStatus so we don't get ugly errors SERVER-2411
https://github.com/mongodb/mongo/commit/4e678efc48b86b9de737a20238d50259b21ab476

Comment by Aristarkh Zagorodnikov [ 01/Feb/11 ]

xm@celestine-3:~$ /opt/mongodb/bin/mongo celestine-3:27017/test1
MongoDB shell version: 1.8.0-rc0-pre-
connecting to: celestine-3:27017/test1
> var f = 0;
unrecognized command: replSetGetStatus

Comment by Aristarkh Zagorodnikov [ 01/Feb/11 ]

Also, consider the following (Git version 9a6f2dcf91c2025f7549c875e78e4a203b26adcf):

xm@celestine-3/opt/mongodb/bin/mongo celestine-3:27017/test1
MongoDB shell version: 1.8.0-rc0-pre-
connecting to: celestine-3:27017/test1
> db.getMongo().slaveOk
unrecognized command: replSetGetStatus
> db.getMongo().slaveOk = true
true
> db.getMongo().slaveOk
true

Comment by Aristarkh Zagorodnikov [ 27/Jan/11 ]

Doesn't appear to be fixed in today's tarball (4eb5359825ca6d7133d0).
xm@celestine-3:~$ ./db/bin/mongo celestine-3
MongoDB shell version: 1.8.0-rc0-pre-
connecting to: celestine-3
> rs.slaveOk()
unrecognized command: replSetGetStatus

Generated at Thu Feb 08 02:59:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.