summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKaloian Manassiev <kaloian.manassiev@mongodb.com>2017-04-11 17:25:40 -0400
committerKaloian Manassiev <kaloian.manassiev@mongodb.com>2017-04-11 18:08:29 -0400
commitd2b45a429985c68fb681f66c309dc279b444a213 (patch)
tree96d04cf151d83b965501572f5e8749fc4b0defbe /src
parentfba4777564145f7f673a23659d06c9eb75fdb54e (diff)
downloadmongo-d2b45a429985c68fb681f66c309dc279b444a213.tar.gz
SERVER-22954 Do not call into the MMAPV1 storage engine on the recipient shard
(cherry picked from commit 921f12c9aa005488ac93b672d74a63af51b93139)
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/s/migration_destination_manager.cpp50
1 files changed, 23 insertions, 27 deletions
diff --git a/src/mongo/db/s/migration_destination_manager.cpp b/src/mongo/db/s/migration_destination_manager.cpp
index 4ca0c148cce..2e748cf3ca9 100644
--- a/src/mongo/db/s/migration_destination_manager.cpp
+++ b/src/mongo/db/s/migration_destination_manager.cpp
@@ -57,7 +57,6 @@
#include "mongo/db/s/sharded_connection_info.h"
#include "mongo/db/s/sharding_state.h"
#include "mongo/db/service_context.h"
-#include "mongo/db/storage/mmap_v1/dur.h"
#include "mongo/logger/ramlog.h"
#include "mongo/s/catalog/type_chunk.h"
#include "mongo/s/shard_key_pattern.h"
@@ -75,6 +74,15 @@ namespace {
Tee* migrateLog = RamLog::get("migrate");
+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);
+
/**
* Returns a human-readabale name of the migration manager's state.
*/
@@ -139,26 +147,26 @@ bool willOverrideLocalId(OperationContext* txn,
bool opReplicatedEnough(OperationContext* txn,
const repl::OpTime& lastOpApplied,
const WriteConcernOptions& writeConcern) {
- WriteConcernOptions majorityWriteConcern;
- majorityWriteConcern.wTimeout = -1;
- majorityWriteConcern.wMode = WriteConcernOptions::kMajority;
- Status majorityStatus = repl::getGlobalReplicationCoordinator()
- ->awaitReplication(txn, lastOpApplied, majorityWriteConcern)
- .status;
-
- if (!writeConcern.shouldWaitForOtherNodes()) {
- return majorityStatus.isOK();
+ WriteConcernResult writeConcernResult;
+
+ Status waitForMajorityWriteConcernStatus =
+ waitForWriteConcern(txn, lastOpApplied, kMajorityWriteConcern, &writeConcernResult);
+ if (!waitForMajorityWriteConcernStatus.isOK()) {
+ return false;
}
// Enforce the user specified write concern after "majority" so it covers the union of the 2
- // write concerns
+ // write concerns in case the user's write concern is stronger than majority
WriteConcernOptions userWriteConcern(writeConcern);
userWriteConcern.wTimeout = -1;
- Status userStatus = repl::getGlobalReplicationCoordinator()
- ->awaitReplication(txn, lastOpApplied, userWriteConcern)
- .status;
- return majorityStatus.isOK() && userStatus.isOK();
+ Status waitForUserWriteConcernStatus =
+ waitForWriteConcern(txn, lastOpApplied, userWriteConcern, &writeConcernResult);
+ if (!waitForUserWriteConcernStatus.isOK()) {
+ return false;
+ }
+
+ return true;
}
/**
@@ -982,18 +990,6 @@ bool MigrationDestinationManager::_flushPendingWrites(OperationContext* txn,
log() << "migrate commit succeeded flushing to secondaries for '" << ns << "' " << min << " -> "
<< max << migrateLog;
- {
- // Get global lock to wait for write to be commited to journal.
- ScopedTransaction scopedXact(txn, MODE_S);
- Lock::GlobalRead lk(txn->lockState());
-
- // if durability is on, force a write to journal
- if (getDur().commitNow(txn)) {
- log() << "migrate commit flushed to journal for '" << ns << "' " << redact(min)
- << " -> " << redact(max) << migrateLog;
- }
- }
-
return true;
}