summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2019-04-06 10:50:40 -0400
committerBenety Goh <benety@mongodb.com>2019-04-06 10:50:57 -0400
commitf48325efba7da7ac93c68dafe8e2f7704a683e1a (patch)
tree22b8aa892645eea44b135de96f796b015554d690 /src/mongo
parentbb12cc699844e8231389a9a878d0b35253cecfa1 (diff)
downloadmongo-f48325efba7da7ac93c68dafe8e2f7704a683e1a.tar.gz
SERVER-39950 OplogApplier::getNextApplierBatch() handles BatchLimit::slaveDelayLatestTimestamp
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/repl/oplog_applier.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/mongo/db/repl/oplog_applier.cpp b/src/mongo/db/repl/oplog_applier.cpp
index 0bdcaaaa018..da1544e4b53 100644
--- a/src/mongo/db/repl/oplog_applier.cpp
+++ b/src/mongo/db/repl/oplog_applier.cpp
@@ -39,6 +39,7 @@
#include "mongo/db/repl/repl_server_parameters_gen.h"
#include "mongo/db/repl/sync_tail.h"
#include "mongo/util/log.h"
+#include "mongo/util/time_support.h"
namespace mongo {
namespace repl {
@@ -213,6 +214,19 @@ StatusWith<OplogApplier::Operations> OplogApplier::getNextApplierBatch(
return {ErrorCodes::BadValue, message};
}
+ if (batchLimits.slaveDelayLatestTimestamp) {
+ auto entryTime =
+ Date_t::fromDurationSinceEpoch(Seconds(entry.getTimestamp().getSecs()));
+ if (entryTime > *batchLimits.slaveDelayLatestTimestamp) {
+ if (ops.empty()) {
+ // Sleep if we've got nothing to do. Only sleep for 1 second at a time to allow
+ // reconfigs and shutdown to occur.
+ sleepsecs(1);
+ }
+ return std::move(ops);
+ }
+ }
+
if (mustProcessStandalone(entry)) {
if (ops.empty()) {
ops.push_back(std::move(entry));