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

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


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

commit 0d75a54d6c4b9f791d911d8fa882e1bfebf43c97
Author: Chenyang Sun <csun5...@gmail.com>
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 e8560a1b9a..98d1a259e8 100644
--- a/be/src/olap/storage_engine.cpp
+++ b/be/src/olap/storage_engine.cpp
@@ -1140,10 +1140,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;
@@ -1152,10 +1156,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: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to