diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/dbcommands.cpp | 7 | ||||
-rw-r--r-- | src/mongo/db/repl_block.cpp | 8 |
2 files changed, 13 insertions, 2 deletions
diff --git a/src/mongo/db/dbcommands.cpp b/src/mongo/db/dbcommands.cpp index 8d1eec45eb0..9a1bfca0228 100644 --- a/src/mongo/db/dbcommands.cpp +++ b/src/mongo/db/dbcommands.cpp @@ -241,6 +241,13 @@ namespace mongo { break; } + if ( !_isMaster() ) { + // this should be in the while loop in case we step down + errmsg = "not master"; + result.append( "wnote", "no longer primary" ); + return false; + } + // check this first for w=0 or w=1 if ( opReplicatedEnough( op, e ) ) { break; diff --git a/src/mongo/db/repl_block.cpp b/src/mongo/db/repl_block.cpp index c312bfab51e..37d9321ea16 100644 --- a/src/mongo/db/repl_block.cpp +++ b/src/mongo/db/repl_block.cpp @@ -168,7 +168,9 @@ namespace mongo { } bool replicatedToNum(OpTime& op, int w) { - if ( w <= 1 || ! _isMaster() ) + massert( 16805, "replicatedToNum called but not master anymore", _isMaster() ); + + if ( w <= 1 ) return true; w--; // now this is the # of slaves i need @@ -177,7 +179,9 @@ namespace mongo { } bool waitForReplication(OpTime& op, int w, int maxSecondsToWait) { - if ( w <= 1 || ! _isMaster() ) + massert( 16806, "waitForReplication called but not master anymore", _isMaster() ); + + if ( w <= 1 ) return true; w--; // now this is the # of slaves i need |