diff options
author | jannaerin <golden.janna@gmail.com> | 2018-09-10 13:13:04 -0700 |
---|---|---|
committer | jannaerin <golden.janna@gmail.com> | 2018-09-18 10:22:16 -0400 |
commit | 07ecc05d44c2a4f443bccf96004a1da16b2e3984 (patch) | |
tree | d9b11c4826975a77484b120b6dd72fbe435e8014 /src/mongo/db/s | |
parent | 3acf1742d7bcec78997614edb1e8ef26ccf2331f (diff) | |
download | mongo-07ecc05d44c2a4f443bccf96004a1da16b2e3984.tar.gz |
SERVER-31892 moveChunk with should wait for majority write concern
Diffstat (limited to 'src/mongo/db/s')
-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 d90b4b2dddf..5297f161948 100644 --- a/src/mongo/db/s/move_chunk_command.cpp +++ b/src/mongo/db/s/move_chunk_command.cpp @@ -64,6 +64,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_FAIL_POINT_DEFINE(moveChunkHangAtStep1); MONGO_FAIL_POINT_DEFINE(moveChunkHangAtStep2); @@ -154,7 +163,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; |