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/12/29 18:58:48 UTC
[kudu] 07/07: [consensus] fix last-heard-from-leader in error
message
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 8a36055bc0f96258e006475f33ecff29ab7caee0
Author: Alexey Serbin <al...@apache.org>
AuthorDate: Thu Dec 26 17:07:29 2019 -0800
[consensus] fix last-heard-from-leader in error message
Fixed the last-heard-from-leader reported time in error message
from TimeManager::AssignTimestamp() when in NON_LEADER mode.
Change-Id: Ic7afdd411f6b23eb690304cf3c8e588e5f08869c
Reviewed-on: http://gerrit.cloudera.org:8080/14952
Tested-by: Alexey Serbin <as...@cloudera.com>
Reviewed-by: Adar Dembo <ad...@cloudera.com>
---
src/kudu/consensus/time_manager.cc | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/src/kudu/consensus/time_manager.cc b/src/kudu/consensus/time_manager.cc
index a83f606..de48fab 100644
--- a/src/kudu/consensus/time_manager.cc
+++ b/src/kudu/consensus/time_manager.cc
@@ -15,17 +15,17 @@
// specific language governing permissions and limitations
// under the License.
+#include "kudu/consensus/time_manager.h"
+
#include <algorithm>
#include <cstdint>
#include <mutex>
#include <ostream>
#include <gflags/gflags.h>
-#include <gflags/gflags_declare.h>
#include <glog/logging.h>
#include "kudu/consensus/consensus.pb.h"
-#include "kudu/consensus/time_manager.h"
#include "kudu/gutil/macros.h"
#include "kudu/gutil/port.h"
#include "kudu/gutil/strings/substitute.h"
@@ -93,9 +93,10 @@ void TimeManager::SetNonLeaderMode() {
Status TimeManager::AssignTimestamp(ReplicateMsg* message) {
Lock l(lock_);
if (PREDICT_FALSE(mode_ == NON_LEADER)) {
- return Status::IllegalState(Substitute("Cannot assign timestamp to transaction. Tablet is not "
- "in leader mode. Last heard from a leader: $0 secs ago.",
- last_advanced_safe_time_.ToString()));
+ return Status::IllegalState(Substitute(
+ "Cannot assign timestamp to transaction. Tablet is not "
+ "in leader mode. Last heard from a leader: $0 ago.",
+ (MonoTime::Now() - last_advanced_safe_time_).ToString()));
}
Timestamp t;
switch (GetMessageConsistencyMode(*message)) {