Skip to content

Commit

Permalink
SERVER-6816 cap repl batches at 1 second or 5000 ops
Browse files Browse the repository at this point in the history
  • Loading branch information
milkie authored and monkey101 committed Sep 13, 2012
1 parent 01f04c8 commit f6dede5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
15 changes: 9 additions & 6 deletions src/mongo/db/repl/rs_sync.cpp
Expand Up @@ -277,7 +277,7 @@ namespace replset {
while( ts < minValid ) {
OpQueue ops;

while (ops.getSize() < replBatchSizeBytes) {
while (ops.getSize() < replBatchLimitBytes) {
if (tryPopAndWaitForMore(&ops)) {
break;
}
Expand Down Expand Up @@ -321,18 +321,21 @@ namespace replset {
// always fetch a few ops first
// tryPopAndWaitForMore returns true when we need to end a batch early
while (!tryPopAndWaitForMore(&ops) &&
(ops.getSize() < replBatchSizeBytes)) {
(ops.getSize() < replBatchLimitBytes)) {

if (theReplSet->isPrimary()) {
return;
}

int now = batchTimer.seconds();

// don't wait more than five seconds building up a batch
if (!ops.empty() && now > replBatchLimitSeconds)
break;

// apply replication batch limits
if (!ops.empty()) {
if (now > replBatchLimitSeconds)
break;
if (ops.getDeque().size() > replBatchLimitOperations)
break;
}
// occasionally check some things
if (ops.empty() || now > lastTimeChecked) {
lastTimeChecked = now;
Expand Down
5 changes: 3 additions & 2 deletions src/mongo/db/repl/rs_sync.h
Expand Up @@ -72,8 +72,9 @@ namespace replset {
protected:
// Cap the batches using the limit on journal commits.
// This works out to be 100 MB (64 bit) or 50 MB (32 bit)
static const unsigned int replBatchSizeBytes = dur::UncommittedBytesLimit;
static const int replBatchLimitSeconds = 5;
static const unsigned int replBatchLimitBytes = dur::UncommittedBytesLimit;
static const int replBatchLimitSeconds = 1;
static const unsigned int replBatchLimitOperations = 5000;

// Prefetch and write a deque of operations, using the supplied function.
// Initial Sync and Sync Tail each use a different function.
Expand Down

0 comments on commit f6dede5

Please sign in to comment.