diff options
author | Benety Goh <benety@mongodb.com> | 2018-05-31 17:02:14 -0400 |
---|---|---|
committer | Benety Goh <benety@mongodb.com> | 2018-05-31 17:02:14 -0400 |
commit | c191447505716af0219eb1c6b03b7b052ef84ddb (patch) | |
tree | 08eaa7702776f03b89413a7f1b1e71c03e6d4992 | |
parent | 392a831a351f4a8229fef5efc3d30b94abff379d (diff) | |
download | mongo-c191447505716af0219eb1c6b03b7b052ef84ddb.tar.gz |
SERVER-32335 move SyncTail::replBatchLimitOperations to OplogApplier
-rw-r--r-- | src/mongo/db/repl/data_replicator_external_state_impl.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog_applier.cpp | 15 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog_applier.h | 5 | ||||
-rw-r--r-- | src/mongo/db/repl/replication_recovery.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/sync_tail.cpp | 24 | ||||
-rw-r--r-- | src/mongo/db/repl/sync_tail.h | 5 |
6 files changed, 23 insertions, 30 deletions
diff --git a/src/mongo/db/repl/data_replicator_external_state_impl.cpp b/src/mongo/db/repl/data_replicator_external_state_impl.cpp index 050a99e15c6..d1c0b7bb963 100644 --- a/src/mongo/db/repl/data_replicator_external_state_impl.cpp +++ b/src/mongo/db/repl/data_replicator_external_state_impl.cpp @@ -153,7 +153,7 @@ StatusWith<OplogApplier::Operations> DataReplicatorExternalStateImpl::getNextApp nullptr, oplogBuffer, nullptr, nullptr, nullptr, nullptr, {}, nullptr); OplogApplier::BatchLimits batchLimits; batchLimits.bytes = SyncTail::replBatchLimitBytes; - batchLimits.ops = std::size_t(SyncTail::replBatchLimitOperations.load()); + batchLimits.ops = OplogApplier::getBatchLimitOperations(); return oplogApplier.getNextApplierBatch(opCtx, batchLimits); } diff --git a/src/mongo/db/repl/oplog_applier.cpp b/src/mongo/db/repl/oplog_applier.cpp index 4e61ab8c79d..d93be1bcb20 100644 --- a/src/mongo/db/repl/oplog_applier.cpp +++ b/src/mongo/db/repl/oplog_applier.cpp @@ -54,6 +54,16 @@ MONGO_EXPORT_STARTUP_SERVER_PARAMETER(replWriterThreadCount, int, 16) return Status::OK(); }); +MONGO_EXPORT_SERVER_PARAMETER(replBatchLimitOperations, int, 50 * 1000) + ->withValidator([](const int& newVal) { + if (newVal < 1 || newVal > (1000 * 1000)) { + return Status(ErrorCodes::BadValue, + "replBatchLimitOperations must be between 1 and 1 million, inclusive"); + } + + return Status::OK(); + }); + } // namespace using CallbackArgs = executor::TaskExecutor::CallbackArgs; @@ -81,6 +91,11 @@ std::unique_ptr<ThreadPool> OplogApplier::makeWriterPool(int threadCount) { return pool; } +// static +std::size_t OplogApplier::getBatchLimitOperations() { + return std::size_t(replBatchLimitOperations.load()); +} + OplogApplier::OplogApplier(executor::TaskExecutor* executor, OplogBuffer* oplogBuffer, Observer* observer, diff --git a/src/mongo/db/repl/oplog_applier.h b/src/mongo/db/repl/oplog_applier.h index fa7f437ac36..dc1639cd0a4 100644 --- a/src/mongo/db/repl/oplog_applier.h +++ b/src/mongo/db/repl/oplog_applier.h @@ -98,6 +98,11 @@ public: static std::unique_ptr<ThreadPool> makeWriterPool(int threadCount); /** + * Returns maximum number of operations in each batch that can be applied using multiApply(). + */ + static std::size_t getBatchLimitOperations(); + + /** * Constructs this OplogApplier with specific options. * Obtains batches of operations from the OplogBuffer to apply. * Reports oplog application progress using the Observer. diff --git a/src/mongo/db/repl/replication_recovery.cpp b/src/mongo/db/repl/replication_recovery.cpp index 153736e018d..613b4aac423 100644 --- a/src/mongo/db/repl/replication_recovery.cpp +++ b/src/mongo/db/repl/replication_recovery.cpp @@ -368,7 +368,7 @@ void ReplicationRecoveryImpl::_applyToEndOfOplog(OperationContext* opCtx, OplogApplier::BatchLimits batchLimits; batchLimits.bytes = SyncTail::calculateBatchLimitBytes(opCtx, _storageInterface); - batchLimits.ops = std::size_t(SyncTail::replBatchLimitOperations.load()); + batchLimits.ops = OplogApplier::getBatchLimitOperations(); OpTime applyThroughOpTime; OplogApplier::Operations batch; diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp index be688de1b9a..b85ee0ba887 100644 --- a/src/mongo/db/repl/sync_tail.cpp +++ b/src/mongo/db/repl/sync_tail.cpp @@ -67,7 +67,6 @@ #include "mongo/db/repl/repl_set_config.h" #include "mongo/db/repl/replication_coordinator.h" #include "mongo/db/repl/session_update_tracker.h" -#include "mongo/db/server_parameters.h" #include "mongo/db/service_context.h" #include "mongo/db/session.h" #include "mongo/db/session_txn_record_gen.h" @@ -86,31 +85,10 @@ using std::endl; namespace repl { -AtomicInt32 SyncTail::replBatchLimitOperations{50 * 1000}; - namespace { MONGO_FAIL_POINT_DEFINE(pauseBatchApplicationBeforeCompletion); -class ExportedBatchLimitOperationsParameter - : public ExportedServerParameter<int, ServerParameterType::kStartupAndRuntime> { -public: - ExportedBatchLimitOperationsParameter() - : ExportedServerParameter<int, ServerParameterType::kStartupAndRuntime>( - ServerParameterSet::getGlobal(), - "replBatchLimitOperations", - &SyncTail::replBatchLimitOperations) {} - - virtual Status validate(const int& potentialNewValue) { - if (potentialNewValue < 1 || potentialNewValue > (1000 * 1000)) { - return Status(ErrorCodes::BadValue, - "replBatchLimitOperations must be between 1 and 1 million, inclusive"); - } - - return Status::OK(); - } -} exportedBatchLimitOperationsParam; - // The oplog entries applied Counter64 opsAppliedStats; ServerStatusMetricField<Counter64> displayOpsApplied("repl.apply.ops", &opsAppliedStats); @@ -746,7 +724,7 @@ private: batchLimits.slaveDelayLatestTimestamp = _calculateSlaveDelayLatestTimestamp(); // Check this once per batch since users can change it at runtime. - batchLimits.ops = replBatchLimitOperations.load(); + batchLimits.ops = OplogApplier::getBatchLimitOperations(); OpQueue ops(batchLimits.ops); // tryPopAndWaitForMore adds to ops and returns true when we need to end a batch early. diff --git a/src/mongo/db/repl/sync_tail.h b/src/mongo/db/repl/sync_tail.h index 81e4ef4bff7..e5aa69c9c04 100644 --- a/src/mongo/db/repl/sync_tail.h +++ b/src/mongo/db/repl/sync_tail.h @@ -71,11 +71,6 @@ public: WorkerMultikeyPathInfo* workerMultikeyPathInfo)>; /** - * Maximum number of operations in each batch that can be applied using multiApply(). - */ - static AtomicInt32 replBatchLimitOperations; - - /** * Lower bound of batch limit size (in bytes) returned by calculateBatchLimitBytes(). */ static const unsigned int replBatchLimitBytes = 100 * 1024 * 1024; |