This is an automated email from the ASF dual-hosted git repository.
dataroaring 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 91c5640cae [fix](tablet clone) fix clone backend chose wrong disk
(#23729)
91c5640cae is described below
commit 91c5640cae529fcfd14eb15c247c04f2f869f365
Author: yujun <[email protected]>
AuthorDate: Fri Sep 1 15:12:35 2023 +0800
[fix](tablet clone) fix clone backend chose wrong disk (#23729)
---
be/src/olap/storage_engine.cpp | 20 ++++++++++++++++----
be/src/olap/storage_engine.h | 4 ++--
be/src/olap/task/engine_clone_task.cpp | 3 ++-
3 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/be/src/olap/storage_engine.cpp b/be/src/olap/storage_engine.cpp
index b25e0862fc..d968c6010a 100644
--- a/be/src/olap/storage_engine.cpp
+++ b/be/src/olap/storage_engine.cpp
@@ -1043,7 +1043,7 @@ Status StorageEngine::create_tablet(const
TCreateTabletReq& request, RuntimeProf
return _tablet_manager->create_tablet(request, stores, profile);
}
-Status StorageEngine::obtain_shard_path(TStorageMedium::type storage_medium,
+Status StorageEngine::obtain_shard_path(TStorageMedium::type storage_medium,
int64_t path_hash,
std::string* shard_path, DataDir**
store) {
LOG(INFO) << "begin to process obtain root path. storage_medium=" <<
storage_medium;
@@ -1058,18 +1058,30 @@ Status
StorageEngine::obtain_shard_path(TStorageMedium::type storage_medium,
"no available disk can be used to create tablet.");
}
+ *store = nullptr;
+ if (path_hash != -1) {
+ for (auto data_dir : stores) {
+ if (data_dir->path_hash() == path_hash) {
+ *store = data_dir;
+ break;
+ }
+ }
+ }
+ if (*store == nullptr) {
+ *store = stores[0];
+ }
+
Status res = Status::OK();
uint64_t shard = 0;
- res = stores[0]->get_shard(&shard);
+ res = (*store)->get_shard(&shard);
if (!res.ok()) {
LOG(WARNING) << "fail to get root path shard. res=" << res;
return res;
}
std::stringstream root_path_stream;
- root_path_stream << stores[0]->path() << "/" << DATA_PREFIX << "/" <<
shard;
+ root_path_stream << (*store)->path() << "/" << DATA_PREFIX << "/" << shard;
*shard_path = root_path_stream.str();
- *store = stores[0];
LOG(INFO) << "success to process obtain root path. path=" << shard_path;
return res;
diff --git a/be/src/olap/storage_engine.h b/be/src/olap/storage_engine.h
index 822f0a458b..b81dcabab5 100644
--- a/be/src/olap/storage_engine.h
+++ b/be/src/olap/storage_engine.h
@@ -122,8 +122,8 @@ public:
//
// @param [out] shard_path choose an available root_path to clone new
tablet
// @return error code
- Status obtain_shard_path(TStorageMedium::type storage_medium, std::string*
shared_path,
- DataDir** store);
+ Status obtain_shard_path(TStorageMedium::type storage_medium, int64_t
path_hash,
+ std::string* shared_path, DataDir** store);
// Load new tablet to make it effective.
//
diff --git a/be/src/olap/task/engine_clone_task.cpp
b/be/src/olap/task/engine_clone_task.cpp
index 19143e1079..9b03375756 100644
--- a/be/src/olap/task/engine_clone_task.cpp
+++ b/be/src/olap/task/engine_clone_task.cpp
@@ -179,7 +179,8 @@ Status EngineCloneTask::_do_clone() {
string local_shard_root_path;
DataDir* store = nullptr;
RETURN_IF_ERROR(StorageEngine::instance()->obtain_shard_path(
- _clone_req.storage_medium, &local_shard_root_path, &store));
+ _clone_req.storage_medium, _clone_req.dest_path_hash,
&local_shard_root_path,
+ &store));
auto tablet_dir = fmt::format("{}/{}/{}", local_shard_root_path,
_clone_req.tablet_id,
_clone_req.schema_hash);
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]