summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Russotto <matthew.russotto@10gen.com>2017-06-27 10:49:53 -0400
committerMatthew Russotto <matthew.russotto@10gen.com>2017-06-27 15:58:59 -0400
commitc9b99e6c1f23e6db4937db041dbba1b247c9e45f (patch)
treecc9a83642b70fb58b791ab3a5178f6539e27ac60
parente11e3c1b9c9ce3f7b4a79493e16f5e4504e01140 (diff)
downloadmongo-c9b99e6c1f23e6db4937db041dbba1b247c9e45f.tar.gz
SERVER-28578 When doing an upgrade from PV0 to PV1, we should not return from the reconfigure until the lastVote document is written.
(cherry picked from commit 62f52d2eba138a8729ac31b589d87bde6f1b5cf5)
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.cpp20
-rw-r--r--src/mongo/db/repl/replication_coordinator_impl.h3
2 files changed, 15 insertions, 8 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp
index 4a1d863c6ac..88e9310d141 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.cpp
+++ b/src/mongo/db/repl/replication_coordinator_impl.cpp
@@ -2378,12 +2378,14 @@ Status ReplicationCoordinatorImpl::processReplSetReconfig(OperationContext* txn,
return status;
}
+ auto finishEvh = uassertStatusOK(_replExecutor.makeEvent());
const stdx::function<void(const ReplicationExecutor::CallbackArgs&)> reconfigFinishFn(
stdx::bind(&ReplicationCoordinatorImpl::_finishReplSetReconfig,
this,
stdx::placeholders::_1,
newConfig,
- myIndex.getValue()));
+ myIndex.getValue(),
+ finishEvh));
// If it's a force reconfig, the primary node may not be electable after the configuration
// change. In case we are that primary node, finish the reconfig under the global lock,
@@ -2395,14 +2397,15 @@ Status ReplicationCoordinatorImpl::processReplSetReconfig(OperationContext* txn,
}
fassert(18824, cbh.getStatus());
configStateGuard.Dismiss();
- _replExecutor.wait(cbh.getValue());
+ _replExecutor.waitForEvent(finishEvh);
return Status::OK();
}
void ReplicationCoordinatorImpl::_finishReplSetReconfig(
const ReplicationExecutor::CallbackArgs& cbData,
const ReplicaSetConfig& newConfig,
- int myIndex) {
+ int myIndex,
+ ReplicationExecutor::EventHandle finishedEvent) {
stdx::unique_lock<stdx::mutex> lk(_mutex);
invariant(_rsConfigState == kConfigReconfiguring);
invariant(_rsConfig.isInitialized());
@@ -2412,12 +2415,15 @@ void ReplicationCoordinatorImpl::_finishReplSetReconfig(
lk.unlock();
auto evh = _resetElectionInfoOnProtocolVersionUpgrade(oldConfig, newConfig);
if (evh) {
- _replExecutor.onEvent(evh,
- [this, action](const ReplicationExecutor::CallbackArgs& cbArgs) {
- _performPostMemberStateUpdateAction(action);
- });
+ _replExecutor.onEvent(
+ evh,
+ [this, action, finishedEvent](const ReplicationExecutor::CallbackArgs& cbArgs) {
+ _performPostMemberStateUpdateAction(action);
+ _replExecutor.signalEvent(finishedEvent);
+ });
} else {
_performPostMemberStateUpdateAction(action);
+ _replExecutor.signalEvent(finishedEvent);
}
}
diff --git a/src/mongo/db/repl/replication_coordinator_impl.h b/src/mongo/db/repl/replication_coordinator_impl.h
index 4253f1ffebe..5f22864311a 100644
--- a/src/mongo/db/repl/replication_coordinator_impl.h
+++ b/src/mongo/db/repl/replication_coordinator_impl.h
@@ -893,7 +893,8 @@ private:
*/
void _finishReplSetReconfig(const ReplicationExecutor::CallbackArgs& cbData,
const ReplicaSetConfig& newConfig,
- int myIndex);
+ int myIndex,
+ ReplicationExecutor::EventHandle finishedEvent);
/**
* Changes _rsConfigState to newState, and notify any waiters.