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

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


The following commit(s) were added to refs/heads/master by this push:
     new c39e72a98 [tablet] fix WriteOp::ToString() for non-started ops
c39e72a98 is described below

commit c39e72a98e124e5a12080bac42105b996594d806
Author: Alexey Serbin <[email protected]>
AuthorDate: Tue Apr 30 21:33:12 2024 -0700

    [tablet] fix WriteOp::ToString() for non-started ops
    
    After [1] and prior to this patch, at least linked_list-test and
    update_scan_delta_compact-test would fail from time to time with
    DCHECK triggered like in the snippet below:
    
      F20240430 19:48:41.064476 2463727 monotime.cc:342] Check failed: 
t_beg.Initialized()
      *** Check failure stack trace: ***
          @     0x7f3c1472548d  google::LogMessage::Fail() at ??:0
          @     0x7f3c147290d7  google::LogMessage::SendToLog() at ??:0
          @     0x7f3c14724e8c  google::LogMessage::Flush() at ??:0
          @     0x7f3c147265c9  google::LogMessageFatal::~LogMessageFatal() at 
??:0
          @     0x7f3c1564dff0  kudu::operator-() at ??:0
          @     0x7f3c1b46a0cd  kudu::tablet::WriteOp::ToString() at ??:0
          @     0x7f3c1b454416  kudu::tablet::OpDriver::ToStringUnlocked() at 
??:0
          @     0x7f3c1b45436f  kudu::tablet::OpDriver::ToString() at ??:0
          @     0x7f3c1b42d154  kudu::tablet::TabletReplica::GetInFlightOps() 
at ??:0
          @     0x7f3c1c121c1d  
kudu::tserver::TabletServerPathHandlers::HandleTransactionsPage() at ??:0
    
    This is a follow-up to [1].
    
    [1] 
https://github.com/apache/kudu/commit/ad3936521af034ffcac637f97cd8c932f6289b4f
    
    Change-Id: Ie4cf49a72d4c7c40c6663a763e79958643fac9a4
    Reviewed-on: http://gerrit.cloudera.org:8080/21381
    Tested-by: Alexey Serbin <[email protected]>
    Reviewed-by: Abhishek Chennaka <[email protected]>
---
 src/kudu/tablet/ops/write_op.cc | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/kudu/tablet/ops/write_op.cc b/src/kudu/tablet/ops/write_op.cc
index 0e2a90cc9..4fe7e9370 100644
--- a/src/kudu/tablet/ops/write_op.cc
+++ b/src/kudu/tablet/ops/write_op.cc
@@ -375,12 +375,20 @@ void WriteOp::Finish(OpResult result) {
 }
 
 string WriteOp::ToString() const {
-  MonoDelta d = MonoTime::Now() - state_->start_time();
-  WallTime abs_time = WallTime_Now() - d.ToSeconds();
-  string abs_time_formatted;
-  StringAppendStrftime(&abs_time_formatted, "%Y-%m-%d %H:%M:%S", 
(time_t)abs_time, true);
+  const auto& start_time = state_->start_time();
+  string start_time_str = "n/a";
+  if (start_time.Initialized()) {
+    const auto d = MonoTime::Now() - start_time;
+    const WallTime abs_time = WallTime_Now() - d.ToSeconds();
+    string abs_time_formatted;
+    StringAppendStrftime(&abs_time_formatted,
+                         "%Y-%m-%d %H:%M:%S",
+                         static_cast<time_t>(abs_time),
+                         true);
+    start_time_str = std::move(abs_time_formatted);
+  }
   return Substitute("WriteOp [type=$0, start_time=$1, state=$2]",
-                    DriverType_Name(type()), abs_time_formatted, 
state_->ToString());
+                    DriverType_Name(type()), start_time_str, 
state_->ToString());
 }
 
 WriteOpState::WriteOpState(TabletReplica* tablet_replica,

Reply via email to