Zardosht Kasheff
unread,May 20, 2013, 11:54:20 PM5/20/13Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to mongo...@googlegroups.com
Hello all,
In Command::execCommand, the code that checks if a command can run on
the given machine seems to be:
bool canRunHere =
isMaster( dbname.c_str() ) ||
c->slaveOk() ||
( c->slaveOverrideOk() && ( queryOptions &
QueryOption_SlaveOk ) ) ||
fromRepl;
This bool is evaluated before any locking occurs for the command
(assuming locking is needed). ReplSetImpl::relinquish() protects the
transition of a machine from RS_PRIMARY to RS_SECONDARY with a global
write lock.
What is to stop the following from happening:
- a command foo executes canRunHere while the machine is still the primary
- canRunHere evaluates to true
- the machine then transitions from primary to secondary
- command foo then grabs its appropriate lock (read or write), and
proceeds to run the command on a secondary, even though it may not be
allowed to do so.
Is this problematic?
Btw, if so, then perhaps the evaluation of canRunHere can move to
inside the lock? It seems like a cheap call. Also, note that calls to
isMasterNs made by inserts, updates, and deletes are all done after a
lock is grabbed.
Thanks
-Zardosht