diff options
author | William Schultz <william.schultz@mongodb.com> | 2020-04-20 16:40:12 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-05-04 18:46:36 +0000 |
commit | 2c34abb5bbf0c89cb22d0ce262afc7e70b11787c (patch) | |
tree | 34c0540f72f8da87de7452d58bc2bf35f157abc4 | |
parent | ad03ae26ddb5cd0b4dcc3977ce4c94e0c6707381 (diff) | |
download | mongo-2c34abb5bbf0c89cb22d0ce262afc7e70b11787c.tar.gz |
SERVER-47636 Handle force reconfig running concurrently with reconfig on step up
(cherry picked from commit 4fe9db02bbd3087c53e481367d2c68e117305557)
-rw-r--r-- | src/mongo/db/repl/replication_coordinator_impl.cpp | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/mongo/db/repl/replication_coordinator_impl.cpp b/src/mongo/db/repl/replication_coordinator_impl.cpp index cdaea4a9843..a46aeccd9ef 100644 --- a/src/mongo/db/repl/replication_coordinator_impl.cpp +++ b/src/mongo/db/repl/replication_coordinator_impl.cpp @@ -1139,13 +1139,19 @@ void ReplicationCoordinatorImpl::signalDrainComplete(OperationContext* opCtx, { // If the config doesn't have a term, don't change it. auto needBumpConfigTerm = _rsConfig.getConfigTerm() != OpTime::kUninitializedTerm; + auto currConfigVersionAndTerm = _rsConfig.getConfigVersionAndTerm(); lk.unlock(); if (needBumpConfigTerm) { // We re-write the term but keep version the same. This conceptually a no-op // in the config consensus group, analogous to writing a new oplog entry // in Raft log state machine on step up. - auto getNewConfig = [&](const ReplSetConfig& oldConfig, long long primaryTerm) { + auto getNewConfig = [&](const ReplSetConfig& oldConfig, + long long primaryTerm) -> StatusWith<ReplSetConfig> { + if (oldConfig.getConfigVersionAndTerm() != currConfigVersionAndTerm) { + return {ErrorCodes::ConfigurationInProgress, + "reconfig on step up was preempted by another reconfig"}; + } auto config = oldConfig; config.setConfigTerm(primaryTerm); return config; |