summaryrefslogtreecommitdiff
path: root/src/mongo/db/logical_clock.cpp
diff options
context:
space:
mode:
authorMisha Tyulenev <misha@mongodb.com>2018-04-12 20:42:21 -0400
committerMisha Tyulenev <misha@mongodb.com>2018-04-12 20:42:39 -0400
commitb7b55e75bbf18bcd7e38fdee430e0fd972183f68 (patch)
treee773e93083c2b4ed6580a3e98261db724f845021 /src/mongo/db/logical_clock.cpp
parent8c59201055adc886541c42b53e72a8b70963ec4a (diff)
downloadmongo-b7b55e75bbf18bcd7e38fdee430e0fd972183f68.tar.gz
SERVER-32639 skip signing and validating clusterTime in arbiters
Diffstat (limited to 'src/mongo/db/logical_clock.cpp')
-rw-r--r--src/mongo/db/logical_clock.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/mongo/db/logical_clock.cpp b/src/mongo/db/logical_clock.cpp
index d8e4d097ef4..a9b7cd62485 100644
--- a/src/mongo/db/logical_clock.cpp
+++ b/src/mongo/db/logical_clock.cpp
@@ -98,6 +98,7 @@ LogicalTime LogicalClock::getClusterTime() {
Status LogicalClock::advanceClusterTime(const LogicalTime newTime) {
stdx::lock_guard<stdx::mutex> lock(_mutex);
+ invariant(_isEnabled);
auto rateLimitStatus = _passesRateLimiter_inlock(newTime);
if (!rateLimitStatus.isOK()) {
@@ -116,6 +117,7 @@ LogicalTime LogicalClock::reserveTicks(uint64_t nTicks) {
invariant(nTicks > 0 && nTicks <= kMaxSignedInt);
stdx::lock_guard<stdx::mutex> lock(_mutex);
+ invariant(_isEnabled);
LogicalTime clusterTime = _clusterTime;
@@ -159,7 +161,6 @@ LogicalTime LogicalClock::reserveTicks(uint64_t nTicks) {
void LogicalClock::setClusterTimeFromTrustedSource(LogicalTime newTime) {
stdx::lock_guard<stdx::mutex> lock(_mutex);
-
// Rate limit checks are skipped here so a server with no activity for longer than
// maxAcceptableLogicalClockDriftSecs seconds can still have its cluster time initialized.
@@ -194,4 +195,14 @@ Status LogicalClock::_passesRateLimiter_inlock(LogicalTime newTime) {
return Status::OK();
}
+bool LogicalClock::isEnabled() const {
+ stdx::lock_guard<stdx::mutex> lock(_mutex);
+ return _isEnabled;
+}
+
+void LogicalClock::setEnabled(bool isEnabled) {
+ stdx::lock_guard<stdx::mutex> lock(_mutex);
+ _isEnabled = isEnabled;
+}
+
} // namespace mongo