You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by ad...@apache.org on 2019/10/16 16:12:56 UTC

[kudu] 02/03: [clock] more info on refusal to advance hybrid timestamp

This is an automated email from the ASF dual-hosted git repository.

adar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit 3bd293d0f32003e877e7f160365ffd238927e164
Author: Alexey Serbin <al...@apache.org>
AuthorDate: Tue Oct 15 10:52:31 2019 -0700

    [clock] more info on refusal to advance hybrid timestamp
    
    Enhanced the error message on the attempt to update hybrid timestamp
    beyond the maximum allowed error threshold.
    
    This patch does not contain any functional changes.
    
    Change-Id: I676fc89fb96fa5383ae354207b64bed3ffe00300
    Reviewed-on: http://gerrit.cloudera.org:8080/14455
    Tested-by: Kudu Jenkins
    Reviewed-by: Adar Dembo <ad...@cloudera.com>
---
 src/kudu/clock/hybrid_clock.cc | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/kudu/clock/hybrid_clock.cc b/src/kudu/clock/hybrid_clock.cc
index 9a8579a..07170f6 100644
--- a/src/kudu/clock/hybrid_clock.cc
+++ b/src/kudu/clock/hybrid_clock.cc
@@ -277,16 +277,20 @@ Status HybridClock::Update(const Timestamp& to_update) {
 
   uint64_t to_update_physical = GetPhysicalValueMicros(to_update);
   uint64_t now_physical = GetPhysicalValueMicros(now);
-
-  // we won't update our clock if to_update is more than 'max_clock_sync_error_usec'
-  // into the future as it might have been corrupted or originated from an out-of-sync
-  // server.
-  if ((to_update_physical - now_physical) > FLAGS_max_clock_sync_error_usec) {
-    return Status::InvalidArgument("Tried to update clock beyond the max. error.");
+  DCHECK_GE(to_update_physical, now_physical);
+
+  // Don't update our clock if 'to_update' is more than
+  // '--max_clock_sync_error_usec' into the future as it might have been
+  // corrupted or originated from an out-of-sync server.
+  if (to_update_physical - now_physical > FLAGS_max_clock_sync_error_usec) {
+    return Status::InvalidArgument(Substitute(
+        "tried to update clock beyond the error threshold of $0us: "
+        "now $1, to_update $2 (now_physical $3, to_update_physical $4)",
+        FLAGS_max_clock_sync_error_usec,
+        now.ToUint64(), to_update.ToUint64(), now_physical, to_update_physical));
   }
 
-  // Our next timestamp must be higher than the one that we are updating
-  // from.
+  // Our next timestamp must be higher than the one that we are updating from.
   next_timestamp_ = to_update.value() + 1;
   return Status::OK();
 }