diff options
author | Eliot Horowitz <eliot@10gen.com> | 2013-04-22 11:35:44 -0400 |
---|---|---|
committer | Eric Milkie <milkie@10gen.com> | 2013-05-08 15:40:05 -0400 |
commit | 779cdd6a8b6cfc70d462a9697672592d553dcdaa (patch) | |
tree | 58750e2eba29b66b2bd34f64e58f8bba3f155574 | |
parent | 84d9196c884edc26f49524c180aa05a6688852b2 (diff) | |
download | mongo-779cdd6a8b6cfc70d462a9697672592d553dcdaa.tar.gz |
SERVER-9417 opReplicatedEnough should assert on step down
-rw-r--r-- | src/mongo/db/dbcommands.cpp | 8 | ||||
-rw-r--r-- | src/mongo/db/repl_block.cpp | 8 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/mongo/db/dbcommands.cpp b/src/mongo/db/dbcommands.cpp index 2b345c70200..86650382847 100644 --- a/src/mongo/db/dbcommands.cpp +++ b/src/mongo/db/dbcommands.cpp @@ -231,6 +231,14 @@ namespace mongo { } while ( 1 ) { + + 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 f32e1ffe90c..4d5795ef1c4 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 |