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

eldenmoon 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 5b4b121fbc9 [Fix](Variant) return status if dict key not found when 
`sync_tablet_rowsets` (#49417)
5b4b121fbc9 is described below

commit 5b4b121fbc9df31b9c56c36c1d29125acdcf1e12
Author: lihangyu <lihan...@selectdb.com>
AuthorDate: Wed Mar 26 22:28:45 2025 +0800

    [Fix](Variant) return status if dict key not found when 
`sync_tablet_rowsets` (#49417)
    
    If meta service version is old, then there's chance to return response
    that the new version of BE can not handle
---
 be/src/cloud/cloud_meta_mgr.cpp | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/be/src/cloud/cloud_meta_mgr.cpp b/be/src/cloud/cloud_meta_mgr.cpp
index cb2fa8cb74b..d6ac44e5d08 100644
--- a/be/src/cloud/cloud_meta_mgr.cpp
+++ b/be/src/cloud/cloud_meta_mgr.cpp
@@ -413,8 +413,8 @@ Status retry_rpc(std::string_view op_name, const Request& 
req, Response* res,
     return Status::RpcError("failed to {}: rpc timeout, last msg={}", op_name, 
error_msg);
 }
 
-static void fill_schema_with_dict(const RowsetMetaCloudPB& in, RowsetMetaPB* 
out,
-                                  const SchemaCloudDictionary& dict) {
+Status fill_schema_with_dict(const RowsetMetaCloudPB& in, RowsetMetaPB* out,
+                             const SchemaCloudDictionary& dict) {
     std::unordered_map<int32_t, ColumnPB*> unique_id_map;
     //init map
     for (ColumnPB& column : *out->mutable_tablet_schema()->mutable_column()) {
@@ -423,6 +423,9 @@ static void fill_schema_with_dict(const RowsetMetaCloudPB& 
in, RowsetMetaPB* out
     // column info
     for (int i = 0; i < in.schema_dict_key_list().column_dict_key_list_size(); 
++i) {
         int dict_key = in.schema_dict_key_list().column_dict_key_list(i);
+        if (dict.column_dict().find(dict_key) == dict.column_dict().end()) {
+            return Status::NotFound("Not found entry {}", dict_key);
+        }
         const ColumnPB& dict_val = dict.column_dict().at(dict_key);
         ColumnPB& to_add = *out->mutable_tablet_schema()->add_column();
         to_add = dict_val;
@@ -432,6 +435,9 @@ static void fill_schema_with_dict(const RowsetMetaCloudPB& 
in, RowsetMetaPB* out
     // index info
     for (int i = 0; i < 
in.schema_dict_key_list().index_info_dict_key_list_size(); ++i) {
         int dict_key = in.schema_dict_key_list().index_info_dict_key_list(i);
+        if (dict.index_dict().find(dict_key) == dict.index_dict().end()) {
+            return Status::NotFound("Not found entry {}", dict_key);
+        }
         const doris::TabletIndexPB& dict_val = dict.index_dict().at(dict_key);
         *out->mutable_tablet_schema()->add_index() = dict_val;
         VLOG_DEBUG << "fill dict index " << dict_val.ShortDebugString();
@@ -440,10 +446,14 @@ static void fill_schema_with_dict(const 
RowsetMetaCloudPB& in, RowsetMetaPB* out
     // sparse column info
     for (int i = 0; i < 
in.schema_dict_key_list().sparse_column_dict_key_list_size(); ++i) {
         int dict_key = 
in.schema_dict_key_list().sparse_column_dict_key_list(i);
+        if (dict.column_dict().find(dict_key) == dict.column_dict().end()) {
+            return Status::NotFound("Not found entry {}", dict_key);
+        }
         const ColumnPB& dict_val = dict.column_dict().at(dict_key);
         *unique_id_map.at(dict_val.parent_unique_id())->add_sparse_columns() = 
dict_val;
         VLOG_DEBUG << "fill dict sparse column" << dict_val.ShortDebugString();
     }
+    return Status::OK();
 }
 
 } // namespace
@@ -648,7 +658,8 @@ Status CloudMetaMgr::sync_tablet_rowsets(CloudTablet* 
tablet, bool warmup_delta_
                     // Otherwise, use the schema dictionary from the response 
(if available).
                     meta_pb = cloud_rowset_meta_to_doris(cloud_rs_meta_pb);
                     if (resp.has_schema_dict()) {
-                        fill_schema_with_dict(cloud_rs_meta_pb, &meta_pb, 
resp.schema_dict());
+                        
RETURN_IF_ERROR(fill_schema_with_dict(cloud_rs_meta_pb, &meta_pb,
+                                                              
resp.schema_dict()));
                     }
                 }
                 auto rs_meta = std::make_shared<RowsetMeta>();


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to