summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Pulo <kevin.pulo@mongodb.com>2017-05-29 07:24:12 +0000
committerKevin Pulo <kevin.pulo@mongodb.com>2017-06-02 10:24:03 +1000
commit0827a5b8aeef04b66914a5c6841f54165035c2a4 (patch)
treeec2e173ee0b6a4bdae051903eceb3622e211c5bb
parent3c47c2f2992fb881622195ef5c045f08061e278b (diff)
downloadmongo-0827a5b8aeef04b66914a5c6841f54165035c2a4.tar.gz
SERVER-29396 maxAcceptableLogicalClockDriftSecs must be positive
Rename parameter to have the "Secs" unit at the end, and prevent it from being 0.
-rw-r--r--src/mongo/db/logical_clock.cpp26
-rw-r--r--src/mongo/db/logical_clock.h4
2 files changed, 15 insertions, 15 deletions
diff --git a/src/mongo/db/logical_clock.cpp b/src/mongo/db/logical_clock.cpp
index c40324f7120..10c76c7a01c 100644
--- a/src/mongo/db/logical_clock.cpp
+++ b/src/mongo/db/logical_clock.cpp
@@ -41,31 +41,31 @@
namespace mongo {
-constexpr Seconds LogicalClock::kMaxAcceptableLogicalClockDrift;
+constexpr Seconds LogicalClock::kMaxAcceptableLogicalClockDriftSecs;
server_parameter_storage_type<long long, ServerParameterType::kStartupOnly>::value_type
- maxAcceptableLogicalClockDrift(LogicalClock::kMaxAcceptableLogicalClockDrift.count());
+ maxAcceptableLogicalClockDriftSecs(LogicalClock::kMaxAcceptableLogicalClockDriftSecs.count());
-class MaxAcceptableLogicalClockDrift
+class MaxAcceptableLogicalClockDriftSecs
: public ExportedServerParameter<long long, ServerParameterType::kStartupOnly> {
public:
- MaxAcceptableLogicalClockDrift()
+ MaxAcceptableLogicalClockDriftSecs()
: ExportedServerParameter<long long, ServerParameterType::kStartupOnly>(
ServerParameterSet::getGlobal(),
- "maxAcceptableLogicalClockDrift",
- &maxAcceptableLogicalClockDrift) {}
+ "maxAcceptableLogicalClockDriftSecs",
+ &maxAcceptableLogicalClockDriftSecs) {}
Status validate(const long long& potentialNewValue) {
- if (potentialNewValue < 0) {
+ if (potentialNewValue <= 0) {
return Status(ErrorCodes::BadValue,
- str::stream() << "maxAcceptableLogicalClockDrift cannot be negative, but "
- "attempted to set to: "
+ str::stream() << "maxAcceptableLogicalClockDriftSecs must be positive, "
+ "but attempted to set to: "
<< potentialNewValue);
}
return Status::OK();
}
-} maxAcceptableLogicalClockDriftParameter;
+} maxAcceptableLogicalClockDriftSecsParameter;
namespace {
const auto getLogicalClock = ServiceContext::declareDecoration<std::unique_ptr<LogicalClock>>();
@@ -154,7 +154,7 @@ 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
- // maxAcceptableLogicalClockDrift seconds can still have its cluster time initialized.
+ // maxAcceptableLogicalClockDriftSecs seconds can still have its cluster time initialized.
if (newTime > _clusterTime) {
_clusterTime = newTime;
@@ -164,11 +164,11 @@ void LogicalClock::setClusterTimeFromTrustedSource(LogicalTime newTime) {
Status LogicalClock::_passesRateLimiter_inlock(LogicalTime newTime) {
const unsigned wallClockSecs =
durationCount<Seconds>(_service->getFastClockSource()->now().toDurationSinceEpoch());
- auto maxAcceptableDrift = static_cast<const unsigned>(maxAcceptableLogicalClockDrift);
+ auto maxAcceptableDriftSecs = static_cast<const unsigned>(maxAcceptableLogicalClockDriftSecs);
auto newTimeSecs = newTime.asTimestamp().getSecs();
// Both values are unsigned, so compare them first to avoid wrap-around.
- if ((newTimeSecs > wallClockSecs) && (newTimeSecs - wallClockSecs) > maxAcceptableDrift) {
+ if ((newTimeSecs > wallClockSecs) && (newTimeSecs - wallClockSecs) > maxAcceptableDriftSecs) {
return Status(ErrorCodes::ClusterTimeFailsRateLimiter,
str::stream() << "New cluster time, " << newTimeSecs
<< ", is too far from this node's wall clock time, "
diff --git a/src/mongo/db/logical_clock.h b/src/mongo/db/logical_clock.h
index 8fbce742aab..3dcbb3e150d 100644
--- a/src/mongo/db/logical_clock.h
+++ b/src/mongo/db/logical_clock.h
@@ -46,7 +46,7 @@ public:
static LogicalClock* get(OperationContext* ctx);
static void set(ServiceContext* service, std::unique_ptr<LogicalClock> logicalClock);
- static constexpr Seconds kMaxAcceptableLogicalClockDrift =
+ static constexpr Seconds kMaxAcceptableLogicalClockDriftSecs =
Seconds(365 * 24 * 60 * 60); // 1 year
/**
@@ -83,7 +83,7 @@ public:
private:
/**
* Rate limiter for advancing logical time. Rejects newTime if its seconds value is more than
- * kMaxAcceptableLogicalClockDrift seconds ahead of this node's wall clock.
+ * kMaxAcceptableLogicalClockDriftSecs seconds ahead of this node's wall clock.
*/
Status _passesRateLimiter_inlock(LogicalTime newTime);