summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2013-04-22 11:35:44 -0400
committerEric Milkie <milkie@10gen.com>2013-06-03 14:26:40 -0400
commitb9225432a8d6a5ee11353f78e5df74df9b3c6451 (patch)
treee3ac89a1009f0a5754d18fc29519d6438cd84fa0
parent819500d00d46fe0e69ce4cfb4398f04ce79b8471 (diff)
downloadmongo-b9225432a8d6a5ee11353f78e5df74df9b3c6451.tar.gz
SERVER-9417 opReplicatedEnough should assert on step down
Conflicts: src/mongo/db/dbcommands.cpp
-rw-r--r--src/mongo/db/dbcommands.cpp7
-rw-r--r--src/mongo/db/repl_block.cpp8
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