Skip to content
Merged
Show file tree
Hide file tree
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
16 changes: 16 additions & 0 deletions be/src/io/fs/local_file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,22 @@ Status LocalFileSystem::delete_directory_impl(const Path& dir) {
return Status::OK();
}

Status LocalFileSystem::delete_directory_or_file(const Path& path) {
bool is_dir;
Status ret = is_directory(path, &is_dir);
if (ret.ok()) {
Status s;
if (is_dir) {
s = delete_directory_impl(path);
} else {
s = delete_file_impl(path);
}
return s;
} else {
return ret;
}
}

Status LocalFileSystem::batch_delete_impl(const std::vector<Path>& files) {
for (auto& file : files) {
RETURN_IF_ERROR(delete_file_impl(file));
Expand Down
2 changes: 2 additions & 0 deletions be/src/io/fs/local_file_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class LocalFileSystem final : public FileSystem {
Status copy_dirs(const Path& src, const Path& dest);
// return true if parent path contain sub path
static bool contain_path(const Path& parent, const Path& sub);
// delete dir or file
Status delete_directory_or_file(const Path& path);

protected:
Status create_file_impl(const Path& file, FileWriterPtr* writer) override;
Expand Down
6 changes: 3 additions & 3 deletions be/src/olap/data_dir.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -723,9 +723,9 @@ void DataDir::_process_garbage_path(const std::string& path) {
return;
}
if (exists) {
LOG(INFO) << "collect garbage dir path: " << path;
WARN_IF_ERROR(io::global_local_filesystem()->delete_directory(path),
"remove garbage dir failed");
LOG(INFO) << "collect garbage path: " << path;
WARN_IF_ERROR(io::global_local_filesystem()->delete_directory_or_file(path),
"remove garbage failed");
}
}

Expand Down
7 changes: 7 additions & 0 deletions be/src/olap/rowset/rowset_meta_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ bool RowsetMetaManager::check_rowset_meta(OlapMeta* meta, TabletUid tablet_uid,
return meta->key_may_exist(META_COLUMN_FAMILY_INDEX, key, &value);
}

Status RowsetMetaManager::exists(OlapMeta* meta, TabletUid tablet_uid, const RowsetId& rowset_id) {
std::string key = ROWSET_PREFIX + tablet_uid.to_string() + "_" + rowset_id.to_string();
std::string value;
Status s = meta->get(META_COLUMN_FAMILY_INDEX, key, &value);
return s;
}

Status RowsetMetaManager::get_rowset_meta(OlapMeta* meta, TabletUid tablet_uid,
const RowsetId& rowset_id,
RowsetMetaSharedPtr rowset_meta) {
Expand Down
1 change: 1 addition & 0 deletions be/src/olap/rowset/rowset_meta_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace doris {
class RowsetMetaManager {
public:
static bool check_rowset_meta(OlapMeta* meta, TabletUid tablet_uid, const RowsetId& rowset_id);
static Status exists(OlapMeta* meta, TabletUid tablet_uid, const RowsetId& rowset_id);

static Status get_rowset_meta(OlapMeta* meta, TabletUid tablet_uid, const RowsetId& rowset_id,
RowsetMetaSharedPtr rowset_meta);
Expand Down
3 changes: 2 additions & 1 deletion be/src/olap/tablet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,8 @@ bool Tablet::check_rowset_id(const RowsetId& rowset_id) {
return true;
}
}
if (RowsetMetaManager::check_rowset_meta(_data_dir->get_meta(), tablet_uid(), rowset_id)) {
Status s = RowsetMetaManager::exists(_data_dir->get_meta(), tablet_uid(), rowset_id);
if (!s.is<META_KEY_NOT_FOUND>()) {
return true;
}
return false;
Expand Down