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

xuyang 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 6ec82ec25c2 [bug](backup) Add table id into convert_rowset_ids() 
(#37089)
6ec82ec25c2 is described below

commit 6ec82ec25c216fd74df170b1e083f07106558d6f
Author: xy720 <22125576+xy...@users.noreply.github.com>
AuthorDate: Mon Jul 15 10:09:50 2024 +0800

    [bug](backup) Add table id into convert_rowset_ids() (#37089)
    
    ## Proposed changes
    
    Issue Number: step 1 in version master in #37076
    
    <!--Describe your changes.-->
---
 be/src/olap/single_replica_compaction.cpp                     | 4 ++--
 be/src/olap/snapshot_manager.cpp                              | 7 +++++--
 be/src/olap/snapshot_manager.h                                | 2 +-
 be/src/olap/task/engine_clone_task.cpp                        | 2 +-
 be/src/olap/task/engine_storage_migration_task.cpp            | 3 ++-
 be/src/runtime/snapshot_loader.cpp                            | 5 +++--
 fe/fe-core/src/main/java/org/apache/doris/task/CloneTask.java | 2 +-
 gensrc/thrift/AgentService.thrift                             | 1 +
 8 files changed, 16 insertions(+), 10 deletions(-)

diff --git a/be/src/olap/single_replica_compaction.cpp 
b/be/src/olap/single_replica_compaction.cpp
index 571156e721c..dfdc0132eec 100644
--- a/be/src/olap/single_replica_compaction.cpp
+++ b/be/src/olap/single_replica_compaction.cpp
@@ -314,8 +314,8 @@ Status SingleReplicaCompaction::_fetch_rowset(const 
TReplicaInfo& addr, const st
     }
     RETURN_IF_ERROR(_download_files(tablet()->data_dir(), remote_url_prefix, 
local_path));
     _pending_rs_guards = DORIS_TRY(_engine.snapshot_mgr()->convert_rowset_ids(
-            local_path, _tablet->tablet_id(), tablet()->replica_id(), 
_tablet->partition_id(),
-            _tablet->schema_hash()));
+            local_path, _tablet->tablet_id(), tablet()->replica_id(), 
_tablet->table_id(),
+            _tablet->partition_id(), _tablet->schema_hash()));
     // 4: finish_clone: create output_rowset and link file
     return _finish_clone(local_data_path, rowset_version);
 }
diff --git a/be/src/olap/snapshot_manager.cpp b/be/src/olap/snapshot_manager.cpp
index e2f117b54e2..ac4f5ee9728 100644
--- a/be/src/olap/snapshot_manager.cpp
+++ b/be/src/olap/snapshot_manager.cpp
@@ -120,8 +120,8 @@ Status SnapshotManager::release_snapshot(const string& 
snapshot_path) {
 }
 
 Result<std::vector<PendingRowsetGuard>> SnapshotManager::convert_rowset_ids(
-        const std::string& clone_dir, int64_t tablet_id, int64_t replica_id, 
int64_t partition_id,
-        int32_t schema_hash) {
+        const std::string& clone_dir, int64_t tablet_id, int64_t replica_id, 
int64_t table_id,
+        int64_t partition_id, int32_t schema_hash) {
     SCOPED_SWITCH_THREAD_MEM_TRACKER_LIMITER(_mem_tracker);
     std::vector<PendingRowsetGuard> guards;
     // check clone dir existed
@@ -151,6 +151,9 @@ Result<std::vector<PendingRowsetGuard>> 
SnapshotManager::convert_rowset_ids(
     new_tablet_meta_pb.set_tablet_id(tablet_id);
     *new_tablet_meta_pb.mutable_tablet_uid() = TabletUid::gen_uid().to_proto();
     new_tablet_meta_pb.set_replica_id(replica_id);
+    if (table_id > 0) {
+        new_tablet_meta_pb.set_table_id(table_id);
+    }
     if (partition_id != -1) {
         new_tablet_meta_pb.set_partition_id(partition_id);
     }
diff --git a/be/src/olap/snapshot_manager.h b/be/src/olap/snapshot_manager.h
index 74225c7976d..df2b1b33b27 100644
--- a/be/src/olap/snapshot_manager.h
+++ b/be/src/olap/snapshot_manager.h
@@ -53,7 +53,7 @@ public:
 
     Result<std::vector<PendingRowsetGuard>> convert_rowset_ids(const 
std::string& clone_dir,
                                                                int64_t 
tablet_id,
-                                                               int64_t 
replica_id,
+                                                               int64_t 
replica_id, int64_t table_id,
                                                                int64_t 
partition_id,
                                                                int32_t 
schema_hash);
 
diff --git a/be/src/olap/task/engine_clone_task.cpp 
b/be/src/olap/task/engine_clone_task.cpp
index a05a640dcfe..40b789cf873 100644
--- a/be/src/olap/task/engine_clone_task.cpp
+++ b/be/src/olap/task/engine_clone_task.cpp
@@ -420,7 +420,7 @@ Status 
EngineCloneTask::_make_and_download_snapshots(DataDir& data_dir,
         }
         // No need to try again with another BE
         _pending_rs_guards = 
DORIS_TRY(_engine.snapshot_mgr()->convert_rowset_ids(
-                local_data_path, _clone_req.tablet_id, _clone_req.replica_id,
+                local_data_path, _clone_req.tablet_id, _clone_req.replica_id, 
_clone_req.table_id,
                 _clone_req.partition_id, _clone_req.schema_hash));
         break;
     } // clone copy from one backend
diff --git a/be/src/olap/task/engine_storage_migration_task.cpp 
b/be/src/olap/task/engine_storage_migration_task.cpp
index 39926d33460..7c870a5e8ea 100644
--- a/be/src/olap/task/engine_storage_migration_task.cpp
+++ b/be/src/olap/task/engine_storage_migration_task.cpp
@@ -159,7 +159,8 @@ Status 
EngineStorageMigrationTask::_gen_and_write_header_to_hdr_file(
     // it will change rowset id and its create time
     // rowset create time is useful when load tablet from meta to check which 
tablet is the tablet to load
     _pending_rs_guards = DORIS_TRY(_engine.snapshot_mgr()->convert_rowset_ids(
-            full_path, tablet_id, _tablet->replica_id(), 
_tablet->partition_id(), schema_hash));
+            full_path, tablet_id, _tablet->replica_id(), _tablet->table_id(),
+            _tablet->partition_id(), schema_hash));
     return Status::OK();
 }
 
diff --git a/be/src/runtime/snapshot_loader.cpp 
b/be/src/runtime/snapshot_loader.cpp
index a742e934ec3..b840636a46f 100644
--- a/be/src/runtime/snapshot_loader.cpp
+++ b/be/src/runtime/snapshot_loader.cpp
@@ -753,8 +753,9 @@ Status SnapshotLoader::move(const std::string& 
snapshot_path, TabletSharedPtr ta
     }
 
     // rename the rowset ids and tabletid info in rowset meta
-    auto res = _engine.snapshot_mgr()->convert_rowset_ids(
-            snapshot_path, tablet_id, tablet->replica_id(), 
tablet->partition_id(), schema_hash);
+    auto res = _engine.snapshot_mgr()->convert_rowset_ids(snapshot_path, 
tablet_id,
+                                                          
tablet->replica_id(), tablet->table_id(),
+                                                          
tablet->partition_id(), schema_hash);
     if (!res.has_value()) [[unlikely]] {
         auto err_msg =
                 fmt::format("failed to convert rowsetids in snapshot: {}, 
tablet path: {}, err: {}",
diff --git a/fe/fe-core/src/main/java/org/apache/doris/task/CloneTask.java 
b/fe/fe-core/src/main/java/org/apache/doris/task/CloneTask.java
index 891ef99c6ed..d1c1ed17734 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/task/CloneTask.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/task/CloneTask.java
@@ -91,7 +91,7 @@ public class CloneTask extends AgentTask {
             request.setDestPathHash(destPathHash);
         }
         request.setTimeoutS(timeoutS);
-
+        request.setTableId(tableId);
         return request;
     }
 
diff --git a/gensrc/thrift/AgentService.thrift 
b/gensrc/thrift/AgentService.thrift
index 76066f9d566..77e050b07a4 100644
--- a/gensrc/thrift/AgentService.thrift
+++ b/gensrc/thrift/AgentService.thrift
@@ -309,6 +309,7 @@ struct TCloneReq {
     10: optional i32 timeout_s;
     11: optional Types.TReplicaId replica_id = 0
     12: optional i64 partition_id
+    13: optional i64 table_id = -1
 }
 
 struct TCompactionReq {


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

Reply via email to