StatusWith<WriteConcernOptions> ChunkMoveWriteConcernOptions::getEffectiveWriteConcern( OperationContext* opCtx, const MigrationSecondaryThrottleOptions& options) { auto secondaryThrottle = options.getSecondaryThrottle(); if (secondaryThrottle == MigrationSecondaryThrottleOptions::kDefault) { if (opCtx->getServiceContext()->getStorageEngine()->supportsDocLocking()) { secondaryThrottle = MigrationSecondaryThrottleOptions::kOff; } else { secondaryThrottle = MigrationSecondaryThrottleOptions::kOn; } } if (secondaryThrottle == MigrationSecondaryThrottleOptions::kOff) { return kWriteConcernLocal; } WriteConcernOptions writeConcern; if (options.isWriteConcernSpecified()) { writeConcern = options.getWriteConcern(); repl::ReplicationCoordinator* replCoordinator = repl::ReplicationCoordinator::get(opCtx); Status status = replCoordinator->checkIfWriteConcernCanBeSatisfied(writeConcern); if (!status.isOK() && status != ErrorCodes::NoReplicationEnabled) { return status; } } else { writeConcern = getDefaultWriteConcernForMigration(opCtx); } if (writeConcern.shouldWaitForOtherNodes() && writeConcern.wTimeout == WriteConcernOptions::kNoTimeout) { // Don't allow no timeout writeConcern.wTimeout = durationCount<Milliseconds>(kDefaultWriteTimeoutForMigration); } return writeConcern; }
StatusWith<WriteConcernOptions> ChunkMoveWriteConcernOptions::getEffectiveWriteConcern( const MigrationSecondaryThrottleOptions& options) { if (options.getSecondaryThrottle() == MigrationSecondaryThrottleOptions::kOff) { return kWriteConcernLocal; } WriteConcernOptions writeConcern; if (options.isWriteConcernSpecified()) { writeConcern = options.getWriteConcern(); repl::ReplicationCoordinator* replCoordinator = repl::getGlobalReplicationCoordinator(); if (replCoordinator->getReplicationMode() == repl::ReplicationCoordinator::modeMasterSlave && writeConcern.shouldWaitForOtherNodes()) { warning() << "moveChunk cannot check if secondary throttle setting " << writeConcern.toBSON() << " can be enforced in a master slave configuration"; } Status status = replCoordinator->checkIfWriteConcernCanBeSatisfied(writeConcern); if (!status.isOK() && status != ErrorCodes::NoReplicationEnabled) { return status; } } else { writeConcern = getDefaultWriteConcernForMigration(); } if (writeConcern.shouldWaitForOtherNodes() && writeConcern.wTimeout == WriteConcernOptions::kNoTimeout) { // Don't allow no timeout writeConcern.wTimeout = durationCount<Milliseconds>(kDefaultWriteTimeoutForMigration); } return writeConcern; }