Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](clone) Fix wrong clone file path #44746

Merged
merged 1 commit into from
Nov 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions be/src/olap/task/engine_clone_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,9 @@ namespace {
/// if not equal, then return error
/// return value: if binlog file not exist, then return to binlog file path
Result<std::string> check_dest_binlog_valid(const std::string& tablet_dir,
const std::string& clone_dir,
const std::string& clone_file, bool* skip_link_file) {
std::string to;
std::string from, to;
std::string new_clone_file = clone_file;
if (clone_file.ends_with(".binlog")) {
// change clone_file suffix from .binlog to .dat
Expand All @@ -92,6 +93,7 @@ Result<std::string> check_dest_binlog_valid(const std::string& tablet_dir,
// change clone_file suffix from .binlog-index to .idx
new_clone_file.replace(clone_file.size() - 13, 13, ".idx");
}
from = fmt::format("{}/{}", clone_dir, clone_file);
to = fmt::format("{}/_binlog/{}", tablet_dir, new_clone_file);

// check to to file exist
Expand All @@ -106,10 +108,10 @@ Result<std::string> check_dest_binlog_valid(const std::string& tablet_dir,
}

LOG(WARNING) << "binlog file already exist. "
<< "tablet_dir=" << tablet_dir << ", clone_file=" << clone_file;
<< "tablet_dir=" << tablet_dir << ", clone_file=" << from << ", to=" << to;

std::string clone_file_md5sum;
status = io::global_local_filesystem()->md5sum(clone_file, &clone_file_md5sum);
status = io::global_local_filesystem()->md5sum(from, &clone_file_md5sum);
if (!status.ok()) {
return ResultError(std::move(status));
}
Expand Down Expand Up @@ -697,7 +699,6 @@ Status EngineCloneTask::_finish_clone(Tablet* tablet, const std::string& clone_d
continue;
}

auto from = fmt::format("{}/{}", clone_dir, clone_file);
std::string to;
if (clone_file.ends_with(".binlog") || clone_file.ends_with(".binlog-index")) {
if (!contain_binlog) {
Expand All @@ -706,7 +707,8 @@ Status EngineCloneTask::_finish_clone(Tablet* tablet, const std::string& clone_d
break;
}

if (auto&& result = check_dest_binlog_valid(tablet_dir, clone_file, &skip_link_file);
if (auto&& result =
check_dest_binlog_valid(tablet_dir, clone_dir, clone_file, &skip_link_file);
result) {
to = std::move(result.value());
} else {
Expand All @@ -718,6 +720,7 @@ Status EngineCloneTask::_finish_clone(Tablet* tablet, const std::string& clone_d
}

if (!skip_link_file) {
auto from = fmt::format("{}/{}", clone_dir, clone_file);
status = io::global_local_filesystem()->link_file(from, to);
if (!status.ok()) {
return status;
Expand Down
Loading