diff options
author | Eliot Horowitz <eliot@10gen.com> | 2013-04-22 11:35:44 -0400 |
---|---|---|
committer | Eric Milkie <milkie@10gen.com> | 2013-06-03 14:26:40 -0400 |
commit | b9225432a8d6a5ee11353f78e5df74df9b3c6451 (patch) | |
tree | e3ac89a1009f0a5754d18fc29519d6438cd84fa0 /src | |
parent | 819500d00d46fe0e69ce4cfb4398f04ce79b8471 (diff) | |
download | mongo-b9225432a8d6a5ee11353f78e5df74df9b3c6451.tar.gz |
SERVER-9417 opReplicatedEnough should assert on step down
Conflicts:
src/mongo/db/dbcommands.cpp
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 |