summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndy Schwerin <schwerin@mongodb.com>2014-10-14 16:38:46 -0400
committerAndy Schwerin <schwerin@mongodb.com>2014-10-27 16:53:29 -0400
commit3c6d2341f54e272990a5b233e7b7eda39bf7d682 (patch)
tree480038f6ea24121d600e529ea93e7d087f04af74 /src
parent07c0c80e190206b8e6f037a885bc5971a78cae3e (diff)
downloadmongo-3c6d2341f54e272990a5b233e7b7eda39bf7d682.tar.gz
SERVER-15535 Consider return value of setFollowerMode in call sites that care.
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/repl/resync.cpp5
-rw-r--r--src/mongo/db/repl/rs_rollback.cpp12
-rw-r--r--src/mongo/db/repl/rs_sync.cpp4
3 files changed, 15 insertions, 6 deletions
diff --git a/src/mongo/db/repl/resync.cpp b/src/mongo/db/repl/resync.cpp
index 915ab0e440b..a1703987676 100644
--- a/src/mongo/db/repl/resync.cpp
+++ b/src/mongo/db/repl/resync.cpp
@@ -75,12 +75,11 @@ namespace repl {
return appendCommandStatus(result, Status(ErrorCodes::NotYetInitialized,
"no replication yet active"));
}
- if (replCoord->getCurrentMemberState().primary()) {
+ if (replCoord->getCurrentMemberState().primary() ||
+ !replCoord->setFollowerMode(MemberState::RS_STARTUP2)) {
return appendCommandStatus(result, Status(ErrorCodes::NotSecondary,
"primaries cannot resync"));
}
-
- replCoord->setFollowerMode(MemberState::RS_STARTUP2);
BackgroundSync::get()->setInitialSyncRequestedFlag(true);
return true;
}
diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp
index 97cafc3d849..ff3c8db959a 100644
--- a/src/mongo/db/repl/rs_rollback.cpp
+++ b/src/mongo/db/repl/rs_rollback.cpp
@@ -730,7 +730,11 @@ namespace {
*
* also, this is better for status reporting - we know what is happening.
*/
- replCoord->setFollowerMode(MemberState::RS_ROLLBACK);
+ if (!replCoord->setFollowerMode(MemberState::RS_ROLLBACK)) {
+ log() << "Cannot transition from " << replCoord->getCurrentMemberState() << " to " <<
+ MemberState(MemberState::RS_ROLLBACK);
+ return 0;
+ }
FixUpInfo how;
log() << "rollback 1";
@@ -778,7 +782,11 @@ namespace {
// success - leave "ROLLBACK" state
// can go to SECONDARY once minvalid is achieved
- replCoord->setFollowerMode(MemberState::RS_RECOVERING);
+ if (!replCoord->setFollowerMode(MemberState::RS_RECOVERING)) {
+ warning() << "Failed to transition into " << MemberState(MemberState::RS_RECOVERING) <<
+ "; expected to be in state " << MemberState(MemberState::RS_ROLLBACK) <<
+ "but found self in " << replCoord->getCurrentMemberState();
+ }
return 0;
}
diff --git a/src/mongo/db/repl/rs_sync.cpp b/src/mongo/db/repl/rs_sync.cpp
index ec31acb65c0..839bae2e188 100644
--- a/src/mongo/db/repl/rs_sync.cpp
+++ b/src/mongo/db/repl/rs_sync.cpp
@@ -213,7 +213,9 @@ namespace repl {
syncDoInitialSync();
continue; // start from top again in case sync failed.
}
- replCoord->setFollowerMode(MemberState::RS_RECOVERING);
+ if (!replCoord->setFollowerMode(MemberState::RS_RECOVERING)) {
+ continue;
+ }
/* we have some data. continue tailing. */
SyncTail tail(BackgroundSync::get(), multiSyncApply);