github-actions[bot] commented on code in PR #27726: URL: https://github.com/apache/doris/pull/27726#discussion_r1435133953
########## be/src/olap/wal_manager.cpp: ########## @@ -66,6 +72,37 @@ } Status WalManager::init() { + RETURN_IF_ERROR(_init_wal_dirs_conf()); + RETURN_IF_ERROR(_init_wal_dirs()); + RETURN_IF_ERROR(_init_wal_disk_info()); + return Thread::create( + "WalMgr", "replay_wal", [this]() { static_cast<void>(this->replay()); }, + &_replay_thread); +} + +Status WalManager::_init_wal_dirs_conf() { + std::vector<std::string> tmp_dirs; + if (_wal_dirs.empty()) { + // default case. + for (const StorePath& path : ExecEnv::GetInstance()->store_paths()) { + tmp_dirs.emplace_back(path.path + "/wal"); + } + } else { + // user config must be absolute path. + for (const std::string& wal_dir : _wal_dirs) { + if (std::filesystem::path(wal_dir).is_absolute()) { + tmp_dirs.emplace_back(wal_dir); + } else { + return Status::InternalError( + "BE config group_commit_replay_wal_dir has to be absolute path!"); + } + } + } + _wal_dirs = tmp_dirs; + return Status::OK(); +} + +Status WalManager::_init_wal_dirs() { Review Comment: warning: method '_init_wal_dirs' can be made static [readability-convert-member-functions-to-static] be/src/olap/wal_manager.h:101: ```diff - Status _init_wal_dirs(); + static Status _init_wal_dirs(); ``` ########## be/src/olap/wal_manager.cpp: ########## @@ -409,4 +472,114 @@ return Status::OK(); } +bool WalManager::is_wal_disk_space_enough() { Review Comment: warning: method 'is_wal_disk_space_enough' can be made static [readability-convert-member-functions-to-static] be/src/olap/wal_manager.h:94: ```diff - bool is_wal_disk_space_enough(); + static bool is_wal_disk_space_enough(); ``` ########## be/src/olap/wal_manager.cpp: ########## @@ -409,4 +472,114 @@ return Status::OK(); } +bool WalManager::is_wal_disk_space_enough() { + // if all disks space usage < 80% + std::shared_lock l(_wal_disk_info_lock); + for (const auto& it : _wal_disk_info_map) { + size_t limit = it.second->limit; + size_t available = it.second->available(); + if (available >= limit * 0.8) { + return true; + } + } + return false; +} + +const string& WalManager::get_min_disk_usage_wal_dir() { + std::shared_lock l(_wal_disk_info_lock); + return _wal_dirs.size() == 1 + ? _wal_dirs[0] + : *std::min_element(_wal_dirs.begin(), _wal_dirs.end(), + [this](const std::string& dir1, const std::string& dir2) { + return _wal_disk_info_map[dir1]->available() < + _wal_disk_info_map[dir2]->available(); + }); +} + +const string& WalManager::get_random_wal_dir() { + std::shared_lock l(_wal_disk_info_lock); + return _wal_disk_info_map.size() == 1 + ? _wal_disk_info_map.begin()->first + : std::next(_wal_disk_info_map.begin(), rand() % _wal_disk_info_map.size()) + ->first; +} + +size_t WalManager::get_max_available_size() { Review Comment: warning: method 'get_max_available_size' can be made static [readability-convert-member-functions-to-static] be/src/olap/wal_manager.h:96: ```diff - size_t get_max_available_size(); + static size_t get_max_available_size(); ``` ########## be/src/olap/wal_manager.cpp: ########## @@ -344,31 +418,20 @@ } } -Status WalManager::delete_wal(int64_t wal_id) { +Status WalManager::delete_wal(int64_t wal_id, size_t block_queue_pre_allocated) { Review Comment: warning: method 'delete_wal' can be made static [readability-convert-member-functions-to-static] be/src/olap/wal_manager.h:67: ```diff - Status delete_wal(int64_t wal_id, size_t block_queue_pre_allocated = 0); + static Status delete_wal(int64_t wal_id, size_t block_queue_pre_allocated = 0); ``` ########## be/src/olap/wal_manager.cpp: ########## @@ -66,6 +72,37 @@ void WalManager::stop() { } Status WalManager::init() { + RETURN_IF_ERROR(_init_wal_dirs_conf()); + RETURN_IF_ERROR(_init_wal_dirs()); + RETURN_IF_ERROR(_init_wal_disk_info()); + return Thread::create( + "WalMgr", "replay_wal", [this]() { static_cast<void>(this->replay()); }, + &_replay_thread); +} + +Status WalManager::_init_wal_dirs_conf() { Review Comment: warning: method '_init_wal_dirs_conf' can be made static [readability-convert-member-functions-to-static] be/src/olap/wal_manager.h:100: ```diff - Status _init_wal_dirs_conf(); + static Status _init_wal_dirs_conf(); ``` ########## be/src/olap/wal_manager.cpp: ########## @@ -80,9 +117,43 @@ } RETURN_IF_ERROR(scan_wals(wal_dir)); } - return Thread::create( - "WalMgr", "replay_wal", [this]() { static_cast<void>(this->replay()); }, - &_replay_thread); + return Status::OK(); +} + +Status WalManager::_init_wal_disk_info() { Review Comment: warning: method '_init_wal_disk_info' can be made static [readability-convert-member-functions-to-static] be/src/olap/wal_manager.h:102: ```diff - Status _init_wal_disk_info(); + static Status _init_wal_disk_info(); ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org