You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by al...@apache.org on 2020/04/07 01:17:59 UTC

[kudu] branch master updated: [master] KUDU-2798 fix logging on deleted TSK entries

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


The following commit(s) were added to refs/heads/master by this push:
     new 63776bc  [master] KUDU-2798 fix logging on deleted TSK entries
63776bc is described below

commit 63776bcabf5f22f305e429620941a2958f6087d5
Author: Alexey Serbin <al...@apache.org>
AuthorDate: Sun Apr 5 23:46:58 2020 -0700

    [master] KUDU-2798 fix logging on deleted TSK entries
    
    Decode the identifiers of the deleted TSK entries while logging.  Prior
    to this patch, the raw value of the system catalog's 'entry_id' column
    was written into the log.
    
    Change-Id: I98c7ba7fd2277fff1176eca51d59404deebe38c4
    Reviewed-on: http://gerrit.cloudera.org:8080/15657
    Reviewed-by: Adar Dembo <ad...@cloudera.com>
    Tested-by: Kudu Jenkins
---
 src/kudu/master/catalog_manager.cc | 12 +++++++++---
 src/kudu/master/sys_catalog.cc     | 13 ++++++++++++-
 src/kudu/master/sys_catalog.h      |  2 ++
 3 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/src/kudu/master/catalog_manager.cc b/src/kudu/master/catalog_manager.cc
index 415b21a..af1b5f1 100644
--- a/src/kudu/master/catalog_manager.cc
+++ b/src/kudu/master/catalog_manager.cc
@@ -4565,7 +4565,7 @@ Status CatalogManager::LoadTskEntries(set<string>* expired_entry_ids) {
   }
   if (expired_entry_ids) {
     set<string> ref(loader.expired_entry_ids());
-    expired_entry_ids->swap(ref);
+    *expired_entry_ids = std::move(ref);
   }
   return master_->token_signer()->ImportKeys(loader.entries());
 }
@@ -4588,8 +4588,14 @@ Status CatalogManager::LoadTspkEntries(vector<TokenSigningPublicKeyPB>* keys) {
 Status CatalogManager::DeleteTskEntries(const set<string>& entry_ids) {
   leader_lock_.AssertAcquiredForWriting();
   RETURN_NOT_OK(sys_catalog_->RemoveTskEntries(entry_ids));
-  LOG_WITH_PREFIX(INFO) << Substitute("Deleted TSKs: $0",
-                                      JoinStrings(entry_ids, ", "));
+  string msg = "Deleted TSKs: ";
+  msg += JoinMapped(
+      entry_ids,
+      [](const string& id) {
+        return Substitute("$0", SysCatalogTable::TskEntryIdToSeqNumber(id));
+      },
+      " ");
+  LOG_WITH_PREFIX(INFO) << msg;
   return Status::OK();
 }
 
diff --git a/src/kudu/master/sys_catalog.cc b/src/kudu/master/sys_catalog.cc
index 571af54..9011cd0 100644
--- a/src/kudu/master/sys_catalog.cc
+++ b/src/kudu/master/sys_catalog.cc
@@ -154,7 +154,7 @@ const char* const SysCatalogTable::kSysCertAuthorityEntryId =
 const char* const SysCatalogTable::kInjectedFailureStatusMsg =
     "INJECTED FAILURE";
 const char* const SysCatalogTable::kLatestNotificationLogEntryIdRowId =
-  "latest_notification_log_entry_id";
+    "latest_notification_log_entry_id";
 
 namespace {
 
@@ -627,6 +627,17 @@ string SysCatalogTable::TskSeqNumberToEntryId(int64_t seq_number) {
   return entry_id;
 }
 
+int64_t SysCatalogTable::TskEntryIdToSeqNumber(const string& entry_id) {
+  Slice to_decode(entry_id);
+  int64_t tsk_seq_id = 0;
+  // Extra parentheses in CHECK_OK() are because of the comma separating types
+  // for the template.
+  CHECK_OK((KeyEncoderTraits<DataType::INT64, string>::DecodeKeyPortion(
+      &to_decode, /* is_last */false, /* arena */nullptr,
+      reinterpret_cast<uint8_t*>(&tsk_seq_id))));
+  return tsk_seq_id;
+}
+
 Status SysCatalogTable::VisitTServerStates(TServerStateVisitor* visitor) {
   TRACE_EVENT0("master", "SysCatalogTable::VisitTServerStates");
   const auto processor = [&] (const string& entry_id,
diff --git a/src/kudu/master/sys_catalog.h b/src/kudu/master/sys_catalog.h
index 35b52a0..d4e9744 100644
--- a/src/kudu/master/sys_catalog.h
+++ b/src/kudu/master/sys_catalog.h
@@ -354,6 +354,8 @@ class SysCatalogTable {
 
   static std::string TskSeqNumberToEntryId(int64_t seq_number);
 
+  static int64_t TskEntryIdToSeqNumber(const std::string& entry_id);
+
   // Special string injected into SyncWrite() random failures (if enabled).
   //
   // Only useful for tests.