Skip to content

Commit

Permalink
[fix](clone) Increase robustness for clone apache#36642 (apache#37413)
Browse files Browse the repository at this point in the history
cherry pick from apache#36642
  • Loading branch information
deardeng authored Jul 9, 2024
1 parent 7f6b846 commit 5247e0f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
7 changes: 6 additions & 1 deletion be/src/olap/single_replica_compaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,12 @@ Status SingleReplicaCompaction::_finish_clone(const string& clone_dir,
}
// clear clone dir
std::filesystem::path clone_dir_path(clone_dir);
std::filesystem::remove_all(clone_dir_path);
std::error_code ec;
std::filesystem::remove_all(clone_dir_path, ec);
if (ec) {
LOG(WARNING) << "failed to remove=" << clone_dir_path << " msg=" << ec.message();
return Status::IOError("failed to remove {}, due to {}", clone_dir, ec.message());
}
LOG(INFO) << "finish to clone data, clear downloaded data. res=" << res
<< ", tablet=" << _tablet->tablet_id() << ", clone_dir=" << clone_dir;
return res;
Expand Down
16 changes: 14 additions & 2 deletions be/src/olap/task/engine_clone_task.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,13 @@ Status EngineCloneTask::_download_files(DataDir* data_dir, const std::string& re
/// 2. Call _finish_xx_clone() to revise the tablet meta.
Status EngineCloneTask::_finish_clone(Tablet* tablet, const std::string& clone_dir, int64_t version,
bool is_incremental_clone) {
Defer remove_clone_dir {[&]() { std::filesystem::remove_all(clone_dir); }};
Defer remove_clone_dir {[&]() {
std::error_code ec;
std::filesystem::remove_all(clone_dir, ec);
if (ec) {
LOG(WARNING) << "failed to remove=" << clone_dir << " msg=" << ec.message();
}
}};

// check clone dir existed
bool exists = true;
Expand Down Expand Up @@ -654,7 +660,13 @@ Status EngineCloneTask::_finish_clone(Tablet* tablet, const std::string& clone_d
bool contain_binlog = false;
RowsetBinlogMetasPB rowset_binlog_metas_pb;
if (binlog_metas_file_exists) {
auto binlog_meta_filesize = std::filesystem::file_size(binlog_metas_file);
std::error_code ec;
auto binlog_meta_filesize = std::filesystem::file_size(binlog_metas_file, ec);
if (ec) {
LOG(WARNING) << "get file size error" << ec.message();
return Status::IOError("can't retrive file_size of {}, due to {}", binlog_metas_file,
ec.message());
}
if (binlog_meta_filesize > 0) {
contain_binlog = true;
RETURN_IF_ERROR(read_pb(binlog_metas_file, &rowset_binlog_metas_pb));
Expand Down

0 comments on commit 5247e0f

Please sign in to comment.