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

kxiao pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-2.0 by this push:
     new b884f9fdf8 [fix](compaction) fix null pointer if single replica 
compaction gets rowset version from peer (#22717)
b884f9fdf8 is described below

commit b884f9fdf8648d8fe20095733698312c6105d39f
Author: Chenyang Sun <[email protected]>
AuthorDate: Wed Aug 9 20:55:24 2023 +0800

    [fix](compaction) fix null pointer if single replica compaction gets rowset 
version from peer (#22717)
---
 be/src/olap/single_replica_compaction.cpp |  6 ++++++
 be/src/olap/storage_engine.cpp            | 16 ++++++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/be/src/olap/single_replica_compaction.cpp 
b/be/src/olap/single_replica_compaction.cpp
index c7671aee36..afe91d9e8e 100644
--- a/be/src/olap/single_replica_compaction.cpp
+++ b/be/src/olap/single_replica_compaction.cpp
@@ -200,6 +200,12 @@ Status 
SingleReplicaCompaction::_get_rowset_verisons_from_peer(
     std::shared_ptr<PBackendService_Stub> stub =
             
ExecEnv::GetInstance()->brpc_internal_client_cache()->get_client(addr.host,
                                                                              
addr.brpc_port);
+    if (stub == nullptr) {
+        LOG(WARNING) << "get rowset versions from peer: get rpc stub failed, 
host = " << addr.host
+                     << " port = " << addr.brpc_port;
+        return Status::Cancelled("get rpc stub failed");
+    }
+
     brpc::Controller cntl;
     stub->get_tablet_rowset_versions(&cntl, &request, &response, nullptr);
     if (cntl.Failed()) {
diff --git a/be/src/olap/storage_engine.cpp b/be/src/olap/storage_engine.cpp
index ee7c9eb5d6..85b1b29650 100644
--- a/be/src/olap/storage_engine.cpp
+++ b/be/src/olap/storage_engine.cpp
@@ -1109,10 +1109,14 @@ void StorageEngine::create_single_replica_compaction(
 
 bool StorageEngine::get_peer_replica_info(int64_t tablet_id, TReplicaInfo* 
replica,
                                           std::string* token) {
+    TabletSharedPtr tablet = _tablet_manager->get_tablet(tablet_id);
+    if (tablet == nullptr) {
+        LOG(WARNING) << "tablet is no longer exist: tablet_id=" << tablet_id;
+        return false;
+    }
     std::unique_lock<std::mutex> lock(_peer_replica_infos_mutex);
     if (_peer_replica_infos.count(tablet_id) &&
-        _peer_replica_infos[tablet_id].replica_id !=
-                _tablet_manager->get_tablet(tablet_id)->replica_id()) {
+        _peer_replica_infos[tablet_id].replica_id != tablet->replica_id()) {
         *replica = _peer_replica_infos[tablet_id];
         *token = _token;
         return true;
@@ -1121,10 +1125,14 @@ bool StorageEngine::get_peer_replica_info(int64_t 
tablet_id, TReplicaInfo* repli
 }
 
 bool StorageEngine::should_fetch_from_peer(int64_t tablet_id) {
+    TabletSharedPtr tablet = _tablet_manager->get_tablet(tablet_id);
+    if (tablet == nullptr) {
+        LOG(WARNING) << "tablet is no longer exist: tablet_id=" << tablet_id;
+        return false;
+    }
     std::unique_lock<std::mutex> lock(_peer_replica_infos_mutex);
     if (_peer_replica_infos.count(tablet_id)) {
-        return _peer_replica_infos[tablet_id].replica_id !=
-               _tablet_manager->get_tablet(tablet_id)->replica_id();
+        return _peer_replica_infos[tablet_id].replica_id != 
tablet->replica_id();
     }
     return false;
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to