You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@impala.apache.org by jo...@apache.org on 2023/02/22 23:23:15 UTC

[impala] branch master updated: IMPALA-11931: enhance ExecutorBlacklist::IsBlacklisted to avoid null pointer exception

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

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


The following commit(s) were added to refs/heads/master by this push:
     new ede002a3e IMPALA-11931: enhance ExecutorBlacklist::IsBlacklisted to avoid null pointer exception
ede002a3e is described below

commit ede002a3e302851215cc0b17d0160e8a5f3eb94c
Author: yx91490 <yx...@126.com>
AuthorDate: Wed Feb 22 14:08:09 2023 +0000

    IMPALA-11931: enhance ExecutorBlacklist::IsBlacklisted to avoid null pointer exception
    
    Testing:
     - add BE test 'ClusterMembershipMgrTest.IsBlacklisted'.
    
    Change-Id: Ib35f5ee1f4c54b2acd62e737ca250f8814e87450
    Reviewed-on: http://gerrit.cloudera.org:8080/19527
    Reviewed-by: Impala Public Jenkins <im...@cloudera.com>
    Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
 be/src/scheduling/cluster-membership-mgr-test.cc | 19 +++++++++++++++++++
 be/src/scheduling/executor-blacklist.cc          | 10 ++++++----
 2 files changed, 25 insertions(+), 4 deletions(-)

diff --git a/be/src/scheduling/cluster-membership-mgr-test.cc b/be/src/scheduling/cluster-membership-mgr-test.cc
index 5773411d8..fd86eead4 100644
--- a/be/src/scheduling/cluster-membership-mgr-test.cc
+++ b/be/src/scheduling/cluster-membership-mgr-test.cc
@@ -353,6 +353,25 @@ TEST_F(ClusterMembershipMgrTest, TwoInstances) {
   ASSERT_EQ(1, GetDefaultGroupSize(cmm2));
 }
 
+TEST_F(ClusterMembershipMgrTest, IsBlacklisted) {
+  const int NUM_BACKENDS = 2;
+  for (int i = 0; i < NUM_BACKENDS; ++i) CreateBackend();
+  EXPECT_EQ(NUM_BACKENDS, backends_.size());
+  EXPECT_EQ(backends_.size(), offline_.size());
+
+  while (!offline_.empty()) CreateCMM(offline_.front());
+  EXPECT_EQ(0, offline_.size());
+  EXPECT_EQ(NUM_BACKENDS, starting_.size());
+
+  while (!starting_.empty()) StartBackend(starting_.front());
+  EXPECT_EQ(0, starting_.size());
+  EXPECT_EQ(NUM_BACKENDS, running_.size());
+
+  backends_[0]->cmm->BlacklistExecutor(backends_[1]->desc->backend_id(), Status("error"));
+  ClusterMembershipMgr::SnapshotPtr snapshot = backends_[0]->cmm->GetSnapshot();
+  EXPECT_TRUE(snapshot->executor_blacklist.IsBlacklisted(*(backends_[1]->desc)));
+}
+
 // This test verifies the interaction between the ExecutorBlacklist and
 // ClusterMembershipMgr.
 TEST_F(ClusterMembershipMgrTest, ExecutorBlacklist) {
diff --git a/be/src/scheduling/executor-blacklist.cc b/be/src/scheduling/executor-blacklist.cc
index 2a561cabb..eaa79288b 100644
--- a/be/src/scheduling/executor-blacklist.cc
+++ b/be/src/scheduling/executor-blacklist.cc
@@ -137,10 +137,12 @@ bool ExecutorBlacklist::IsBlacklisted(
     const Entry& entry = entry_it->second;
     if (entry.state == State::BLACKLISTED) {
       if (cause != nullptr) *cause = entry.cause;
-      int64_t elapsed_ms = MonotonicMillis() - entry.blacklist_time_ms;
-      int64_t total_timeout_ms =
-          GetBlacklistTimeoutMs() * entry.num_consecutive_blacklistings;
-      *time_remaining_ms = total_timeout_ms - elapsed_ms;
+      if (time_remaining_ms != nullptr) {
+        int64_t elapsed_ms = MonotonicMillis() - entry.blacklist_time_ms;
+        int64_t total_timeout_ms =
+            GetBlacklistTimeoutMs() * entry.num_consecutive_blacklistings;
+        *time_remaining_ms = total_timeout_ms - elapsed_ms;
+      }
       return true;
     }
   }