Skip to content

branch-3.0: [enhancement](cloud) make file cache version upgrade faster #50726 #51194

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

Merged
merged 1 commit into from
May 28, 2025
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
9 changes: 5 additions & 4 deletions be/src/common/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,7 @@ DEFINE_Int32(num_cores, "0");
// When BE start, If there is a broken disk, BE process will exit by default.
// Otherwise, we will ignore the broken disk,
DEFINE_Bool(ignore_broken_disk, "false");
DEFINE_Bool(ignore_file_cache_dir_upgrade_failure, "false");

// Sleep time in milliseconds between memory maintenance iterations
DEFINE_mInt32(memory_maintenance_sleep_time_ms, "20");
Expand Down Expand Up @@ -1084,11 +1085,11 @@ DEFINE_Int64(file_cache_each_block_size, "1048576"); // 1MB

DEFINE_Bool(clear_file_cache, "false");
DEFINE_Bool(enable_file_cache_query_limit, "false");
DEFINE_mInt32(file_cache_enter_disk_resource_limit_mode_percent, "88");
DEFINE_mInt32(file_cache_exit_disk_resource_limit_mode_percent, "80");
DEFINE_mInt32(file_cache_enter_disk_resource_limit_mode_percent, "90");
DEFINE_mInt32(file_cache_exit_disk_resource_limit_mode_percent, "88");
DEFINE_mBool(enable_evict_file_cache_in_advance, "true");
DEFINE_mInt32(file_cache_enter_need_evict_cache_in_advance_percent, "78");
DEFINE_mInt32(file_cache_exit_need_evict_cache_in_advance_percent, "75");
DEFINE_mInt32(file_cache_enter_need_evict_cache_in_advance_percent, "88");
DEFINE_mInt32(file_cache_exit_need_evict_cache_in_advance_percent, "85");
DEFINE_mInt32(file_cache_evict_in_advance_interval_ms, "1000");
DEFINE_mInt64(file_cache_evict_in_advance_batch_bytes, "31457280"); // 30MB
DEFINE_mInt64(file_cache_evict_in_advance_recycle_keys_num_threshold, "1000");
Expand Down
1 change: 1 addition & 0 deletions be/src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -700,6 +700,7 @@ DECLARE_Int32(num_cores);
// When BE start, If there is a broken disk, BE process will exit by default.
// Otherwise, we will ignore the broken disk,
DECLARE_Bool(ignore_broken_disk);
DECLARE_Bool(ignore_file_cache_dir_upgrade_failure);

// Sleep time in milliseconds between memory maintenance iterations
DECLARE_mInt32(memory_maintenance_sleep_time_ms);
Expand Down
2 changes: 2 additions & 0 deletions be/src/common/status.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace ErrorCode {
TStatusError(IO_ERROR, true); \
TStatusError(NOT_FOUND, true); \
TStatusError(ALREADY_EXIST, true); \
TStatusError(DIRECTORY_NOT_EMPTY, true); \
TStatusError(NOT_IMPLEMENTED_ERROR, false); \
TStatusError(END_OF_FILE, false); \
TStatusError(INTERNAL_ERROR, true); \
Expand Down Expand Up @@ -471,6 +472,7 @@ class [[nodiscard]] Status {
ERROR_CTOR(IOError, IO_ERROR)
ERROR_CTOR(NotFound, NOT_FOUND)
ERROR_CTOR_NOSTACK(AlreadyExist, ALREADY_EXIST)
ERROR_CTOR_NOSTACK(DirectoryNotEmpty, DIRECTORY_NOT_EMPTY)
ERROR_CTOR(NotSupported, NOT_IMPLEMENTED_ERROR)
ERROR_CTOR_NOSTACK(EndOfFile, END_OF_FILE)
ERROR_CTOR(InternalError, INTERNAL_ERROR)
Expand Down
267 changes: 197 additions & 70 deletions be/src/io/cache/fs_file_cache_storage.cpp

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions be/src/io/cache/fs_file_cache_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#pragma once

#include <bvar/bvar.h>

#include <memory>
#include <shared_mutex>
#include <thread>
Expand Down Expand Up @@ -87,6 +89,11 @@ class FSFileCacheStorage : public FileCacheStorage {
FileCacheStorageType get_type() override { return DISK; }

private:
void remove_old_version_directories();

Status collect_directory_entries(const std::filesystem::path& dir_path,
std::vector<std::string>& file_list) const;

Status upgrade_cache_dir_if_necessary() const;

Status read_file_cache_version(std::string* buffer) const;
Expand All @@ -111,6 +118,7 @@ class FSFileCacheStorage : public FileCacheStorage {
// TODO(Lchangliang): use a more efficient data structure
std::mutex _mtx;
std::unordered_map<FileWriterMapKey, FileWriterPtr, FileWriterMapKeyHash> _key_to_writer;
std::shared_ptr<bvar::LatencyRecorder> _iterator_dir_retry_cnt;
};

} // namespace doris::io
2 changes: 2 additions & 0 deletions be/src/io/fs/err_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ Status localfs_error(const std::error_code& ec, std::string_view msg) {
return Status::Error<DISK_REACH_CAPACITY_LIMIT, false>(message);
} else if (ec == std::errc::permission_denied) {
return Status::Error<PERMISSION_DENIED, false>(message);
} else if (ec == std::errc::directory_not_empty) {
return Status::Error<DIRECTORY_NOT_EMPTY, false>(message);
} else {
return Status::Error<ErrorCode::INTERNAL_ERROR, false>(message);
}
Expand Down
3 changes: 1 addition & 2 deletions be/src/runtime/exec_env_init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ Status ExecEnv::_init(const std::vector<StorePath>& store_paths,
.set_min_threads(config::min_s3_file_system_thread_num)
.set_max_threads(config::max_s3_file_system_thread_num)
.build(&_s3_file_system_thread_pool));
RETURN_IF_ERROR(_init_mem_env());

// NOTE: runtime query statistics mgr could be visited by query and daemon thread
// so it should be created before all query begin and deleted after all query and daemon thread stoppped
Expand Down Expand Up @@ -304,8 +305,6 @@ Status ExecEnv::_init(const std::vector<StorePath>& store_paths,
return status;
}

RETURN_IF_ERROR(_init_mem_env());

RETURN_IF_ERROR(_memtable_memory_limiter->init(MemInfo::mem_limit()));
RETURN_IF_ERROR(_load_channel_mgr->init(MemInfo::mem_limit()));
RETURN_IF_ERROR(_wal_manager->init());
Expand Down
Loading
Loading