summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2018-05-09 17:31:10 -0400
committerBenety Goh <benety@mongodb.com>2018-05-09 17:31:10 -0400
commita9ff8390522ee74d41141235b977c41c166aa38e (patch)
treeb08930925af7aea93e12b1297b3f609e87decb42 /src
parentb6b9c9a40cebbca123dc7354c6cefb8f856f815b (diff)
downloadmongo-a9ff8390522ee74d41141235b977c41c166aa38e.tar.gz
SERVER-32335 make SyncTail::OpQueue accept the maximum number of ops in a batch.
This makes it unnecessary to reference the static variable replBatchLimitOperations at construction.
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/repl/sync_tail.cpp5
-rw-r--r--src/mongo/db/repl/sync_tail.h4
2 files changed, 5 insertions, 4 deletions
diff --git a/src/mongo/db/repl/sync_tail.cpp b/src/mongo/db/repl/sync_tail.cpp
index f48ea88dd09..cc6343dd665 100644
--- a/src/mongo/db/repl/sync_tail.cpp
+++ b/src/mongo/db/repl/sync_tail.cpp
@@ -742,6 +742,7 @@ public:
: _syncTail(syncTail),
_storageInterface(storageInterface),
_oplogBuffer(oplogBuffer),
+ _ops(0),
_thread([this] { run(); }) {}
~OpQueueBatcher() {
invariant(_isDead);
@@ -757,7 +758,7 @@ public:
}
OpQueue ops = std::move(_ops);
- _ops = {};
+ _ops = OpQueue(0);
_cv.notify_all();
return ops;
@@ -792,7 +793,7 @@ private:
// Check this once per batch since users can change it at runtime.
batchLimits.ops = replBatchLimitOperations.load();
- OpQueue ops;
+ OpQueue ops(batchLimits.ops);
// tryPopAndWaitForMore adds to ops and returns true when we need to end a batch early.
{
auto opCtx = cc().makeOperationContext();
diff --git a/src/mongo/db/repl/sync_tail.h b/src/mongo/db/repl/sync_tail.h
index 67fe9cf6ef5..233026c52f9 100644
--- a/src/mongo/db/repl/sync_tail.h
+++ b/src/mongo/db/repl/sync_tail.h
@@ -150,8 +150,8 @@ public:
class OpQueue {
public:
- OpQueue() : _bytes(0) {
- _batch.reserve(replBatchLimitOperations.load());
+ explicit OpQueue(std::size_t batchLimitOps) : _bytes(0) {
+ _batch.reserve(batchLimitOps);
}
size_t getBytes() const {