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

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

commit 60d5a710f598edbffe9e6e3193b0135f904b04f3
Author: Ashwani Raina <ara...@cloudera.com>
AuthorDate: Mon Mar 27 15:09:59 2023 +0530

    [client] Improve logging in client metacache
    
    As part for impala crashing issue KUDU-3461 (caused due to PickLeader
    getting called recursively for indefinite iterations until stack
    overflow happens), some extra logs are added to aid in debugging for
    future issues that may reside in the code path mentioned above.
    
    Change-Id: I2a47f643307ef47a98b1d3481b4c03834fa239d4
    Reviewed-on: http://gerrit.cloudera.org:8080/19653
    Tested-by: Kudu Jenkins
    Reviewed-by: Yingchun Lai <laiyingc...@apache.org>
    Reviewed-by: Abhishek Chennaka <achenn...@cloudera.com>
---
 src/kudu/client/meta_cache.cc | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/src/kudu/client/meta_cache.cc b/src/kudu/client/meta_cache.cc
index fed115d04..02cbe15df 100644
--- a/src/kudu/client/meta_cache.cc
+++ b/src/kudu/client/meta_cache.cc
@@ -279,6 +279,7 @@ Status RemoteTablet::Refresh(
 }
 
 void RemoteTablet::MarkStale() {
+  VLOG(1) << "Marking tablet stale, tablet id " << tablet_id_;
   stale_ = true;
 }
 
@@ -461,6 +462,14 @@ void MetaCacheServerPicker::PickLeader(const 
ServerPickedCallback& callback,
   RemoteTabletServer* leader = nullptr;
   if (!tablet_->stale()) {
     leader = tablet_->LeaderTServer();
+    if (leader) {
+      VLOG(1) << "Client copy of tablet " << tablet_->tablet_id()
+              << " is fresh, leader uuid " << leader->permanent_uuid();
+    } else {
+      VLOG(1) << "Client copy of tablet " << tablet_->tablet_id()
+              << " is fresh (no leader).";
+    }
+
     bool marked_as_follower = false;
     {
       std::lock_guard<simple_spinlock> lock(lock_);
@@ -501,6 +510,8 @@ void MetaCacheServerPicker::PickLeader(const 
ServerPickedCallback& callback,
             << "Preemptively marking tserver " << leader->ToString()
             << " as leader in the meta cache.";
         tablet_->MarkTServerAsLeader(leader);
+      } else {
+        VLOG(1) << "Tablet " << tablet_->tablet_id() << ": No valid leader.";
       }
     }
   }
@@ -518,6 +529,7 @@ void MetaCacheServerPicker::PickLeader(const 
ServerPickedCallback& callback,
   // shift the write to another tablet (i.e. if it's since been split).
   if (!leader) {
     if (table_) {
+      VLOG(1) << "Table " << table_->name() << ": No valid leader, lookup 
tablet by key.";
       meta_cache_->LookupTabletByKey(
           table_,
           tablet_->partition().begin(),
@@ -528,6 +540,7 @@ void MetaCacheServerPicker::PickLeader(const 
ServerPickedCallback& callback,
             this->LookUpTabletCb(callback, deadline, s);
           });
     } else {
+      VLOG(1) << "No valid table or leader: lookup tablet by ID " << 
tablet_->tablet_id();
       meta_cache_->LookupTabletById(
           client_,
           tablet_->tablet_id(),
@@ -1212,17 +1225,22 @@ bool MetaCache::LookupEntryByKeyFastPath(const 
KuduTable* table,
   const TabletMap* tablets = FindOrNull(tablets_by_table_and_key_, 
table->id());
   if (PREDICT_FALSE(!tablets)) {
     // No cache available for this table.
+    VLOG(1) << "No cache available for table " << table->name();
     return false;
   }
 
   const MetaCacheEntry* e = FindFloorOrNull(*tablets, partition_key);
   if (PREDICT_FALSE(!e)) {
     // No tablets with a start partition key lower than 'partition_key'.
+    VLOG(1) << "Table " << table->name()
+            << ": No tablets found with a start key lower than input key.";
     return false;
   }
 
   // Stale entries must be re-fetched.
   if (e->stale()) {
+    VLOG(1) << "Table " << table->name() << ": Stale entry for tablet "
+            << e->tablet()->tablet_id() << " found, must be re-fetched.";
     return false;
   }
 
@@ -1231,6 +1249,7 @@ bool MetaCache::LookupEntryByKeyFastPath(const KuduTable* 
table,
     return true;
   }
 
+  VLOG(1) << "Table " << table->name() << ": LookupEntryByKeyFastPath failed!";
   return false;
 }
 
@@ -1409,6 +1428,8 @@ void MetaCache::LookupTabletByKey(const KuduTable* table,
     return;
   }
 
+  VLOG(1) << "Fastpath lookup failed with " << fastpath_status.ToString()
+          << ". Proceed with rpc lookup, table: " << table->name();
   LookupRpc* rpc = new LookupRpc(this,
                                  callback,
                                  table,

Reply via email to