diff options
author | Tess Avitabile <tess.avitabile@mongodb.com> | 2019-05-08 10:49:53 -0400 |
---|---|---|
committer | Tess Avitabile <tess.avitabile@mongodb.com> | 2019-05-10 09:17:02 -0400 |
commit | 887e13622f1e3ffecefbed4f42bae62666680ee4 (patch) | |
tree | 83fac5044f6330d37187977198e235a018994068 | |
parent | 848b0c21638d6b1731385d0ead2d138b6c436515 (diff) | |
download | mongo-887e13622f1e3ffecefbed4f42bae62666680ee4.tar.gz |
SERVER-41006 Make replBatchLimitBytes configurable
-rw-r--r-- | src/mongo/db/repl/initial_syncer.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog_applier.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/repl/oplog_applier.h | 5 | ||||
-rw-r--r-- | src/mongo/db/repl/repl_server_parameters.idl | 13 | ||||
-rw-r--r-- | src/mongo/db/repl/sync_tail.cpp | 6 |
5 files changed, 18 insertions, 10 deletions
diff --git a/src/mongo/db/repl/initial_syncer.cpp b/src/mongo/db/repl/initial_syncer.cpp index 4733e69ea10..335411ca1ba 100644 --- a/src/mongo/db/repl/initial_syncer.cpp +++ b/src/mongo/db/repl/initial_syncer.cpp @@ -1685,7 +1685,7 @@ StatusWith<Operations> InitialSyncer::_getNextApplierBatch_inlock() { // Obtain next batch of operations from OplogApplier. auto opCtx = makeOpCtx(); OplogApplier::BatchLimits batchLimits; - batchLimits.bytes = OplogApplier::replBatchLimitBytes; + batchLimits.bytes = replBatchLimitBytes.load(); batchLimits.ops = OplogApplier::getBatchLimitOperations(); return _oplogApplier->getNextApplierBatch(opCtx.get(), batchLimits); } diff --git a/src/mongo/db/repl/oplog_applier.cpp b/src/mongo/db/repl/oplog_applier.cpp index 7e6010aa77c..a44cb2ab410 100644 --- a/src/mongo/db/repl/oplog_applier.cpp +++ b/src/mongo/db/repl/oplog_applier.cpp @@ -77,7 +77,7 @@ std::size_t OplogApplier::calculateBatchLimitBytes(OperationContext* opCtx, auto oplogMaxSizeResult = storageInterface->getOplogMaxSize(opCtx, NamespaceString::kRsOplogNamespace); auto oplogMaxSize = fassert(40301, oplogMaxSizeResult); - return std::min(oplogMaxSize / 10, std::size_t(replBatchLimitBytes)); + return std::min(oplogMaxSize / 10, std::size_t(replBatchLimitBytes.load())); } OplogApplier::OplogApplier(executor::TaskExecutor* executor, diff --git a/src/mongo/db/repl/oplog_applier.h b/src/mongo/db/repl/oplog_applier.h index 49477ac03ec..0966ec3b960 100644 --- a/src/mongo/db/repl/oplog_applier.h +++ b/src/mongo/db/repl/oplog_applier.h @@ -104,11 +104,6 @@ public: OperationContext* opCtx, const BatchLimits& batchLimits)>; /** - * Lower bound of batch limit size (in bytes) returned by calculateBatchLimitBytes(). - */ - static const unsigned int replBatchLimitBytes = 100 * 1024 * 1024; - - /** * Creates thread pool for writer tasks. */ static std::unique_ptr<ThreadPool> makeWriterPool(); diff --git a/src/mongo/db/repl/repl_server_parameters.idl b/src/mongo/db/repl/repl_server_parameters.idl index b7b2447649a..ba56ea21c4d 100644 --- a/src/mongo/db/repl/repl_server_parameters.idl +++ b/src/mongo/db/repl/repl_server_parameters.idl @@ -237,3 +237,16 @@ server_parameters: lte: expr: 1000 * 1000 + replBatchLimitBytes: + description: The maximum oplog application batch size in bytes + set_at: [ startup, runtime ] + cpp_vartype: AtomicWord<int> + cpp_varname: replBatchLimitBytes + default: + expr: 100 * 1024 * 1024 + validator: + gte: + expr: 16 * 1024 * 1024 + lte: + expr: 100 * 1024 * 1024 + diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp index a3dcb97e410..0b93b7d373b 100644 --- a/src/mongo/db/repl/sync_tail.cpp +++ b/src/mongo/db/repl/sync_tail.cpp @@ -633,16 +633,16 @@ private: Client::initThread("ReplBatcher"); BatchLimits batchLimits; - batchLimits.bytes = OplogApplier::calculateBatchLimitBytes( - cc().makeOperationContext().get(), _storageInterface); while (true) { MONGO_FAIL_POINT_PAUSE_WHILE_SET(rsSyncApplyStop); batchLimits.slaveDelayLatestTimestamp = _calculateSlaveDelayLatestTimestamp(); - // Check this once per batch since users can change it at runtime. + // Check the limits once per batch since users can change them at runtime. batchLimits.ops = OplogApplier::getBatchLimitOperations(); + batchLimits.bytes = OplogApplier::calculateBatchLimitBytes( + cc().makeOperationContext().get(), _storageInterface); OpQueue ops(batchLimits.ops); { |