diff options
author | jannaerin <golden.janna@gmail.com> | 2018-09-10 13:13:04 -0700 |
---|---|---|
committer | jannaerin <golden.janna@gmail.com> | 2018-10-08 13:23:30 -0400 |
commit | 05641d1216ffe2b0b0612863b5380d608eb74532 (patch) | |
tree | 3dd18090192b786a44f8a22713fdce2c5030664f | |
parent | 102569db3158bfa5b70307251de156cee53182d0 (diff) | |
download | mongo-05641d1216ffe2b0b0612863b5380d608eb74532.tar.gz |
SERVER-31892 moveChunk with should wait for majority write concern
(cherry picked from commit 07ecc05d44c2a4f443bccf96004a1da16b2e3984)
-rw-r--r-- | src/mongo/db/s/move_chunk_command.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/mongo/db/s/move_chunk_command.cpp b/src/mongo/db/s/move_chunk_command.cpp index 235e053a3f8..ea5c9ebee15 100644 --- a/src/mongo/db/s/move_chunk_command.cpp +++ b/src/mongo/db/s/move_chunk_command.cpp @@ -63,6 +63,15 @@ void uassertStatusOKWithWarning(const Status& status) { } } +const WriteConcernOptions kMajorityWriteConcern(WriteConcernOptions::kMajority, + // Note: Even though we're setting UNSET here, + // kMajority implies JOURNAL if journaling is + // supported by mongod and + // writeConcernMajorityJournalDefault is set to true + // in the ReplSetConfig. + WriteConcernOptions::SyncMode::UNSET, + -1); + // Tests can pause and resume moveChunk's progress at each step by enabling/disabling each failpoint MONGO_FP_DECLARE(moveChunkHangAtStep1); MONGO_FP_DECLARE(moveChunkHangAtStep2); @@ -163,7 +172,19 @@ public: // OperationContext. // TODO (SERVER-30183): If this moveChunk joined an active moveChunk that did not have // waitForDelete=true, the captured opTime may not reflect all the deletes. - repl::ReplClientInfo::forClient(opCtx->getClient()).setLastOpToSystemLastOpTime(opCtx); + auto& replClient = repl::ReplClientInfo::forClient(opCtx->getClient()); + replClient.setLastOpToSystemLastOpTime(opCtx); + + WriteConcernResult writeConcernResult; + writeConcernResult.wTimedOut = false; + Status majorityStatus = waitForWriteConcern( + opCtx, replClient.getLastOp(), kMajorityWriteConcern, &writeConcernResult); + if (!majorityStatus.isOK()) { + if (!writeConcernResult.wTimedOut) { + uassertStatusOK(majorityStatus); + } + return false; + } } return true; |