morningman commented on code in PR #16767:
URL: https://github.com/apache/doris/pull/16767#discussion_r1106698431
##########
be/src/io/cache/block/block_lru_file_cache.cpp:
##########
@@ -634,63 +637,113 @@ void LRUFileCache::remove(const Key& key, bool
is_persistent, size_t offset,
}
void LRUFileCache::load_cache_info_into_memory(std::lock_guard<std::mutex>&
cache_lock) {
+ /// version 1.0: cache_base_path / key / offset
+ /// version 2.0: cache_base_path / key_prefix / key / offset
+ if (read_file_cache_version() != FILE_CACHE_VERSION) {
+ // move directories format as version 2.0
+ fs::directory_iterator key_it {_cache_base_path};
+ for (; key_it != fs::directory_iterator(); ++key_it) {
+ if (key_it->is_directory()) {
+ std::string cache_key = key_it->path().filename().native();
+ if (cache_key.size() > KEY_PREFIX_LENGTH) {
+ std::string key_prefix =
+ fs::path(_cache_base_path) / cache_key.substr(0,
KEY_PREFIX_LENGTH);
+ if (!fs::exists(key_prefix)) {
+ std::error_code ec;
+ fs::create_directories(key_prefix, ec);
+ if (ec) {
+ LOG(WARNING) << "Failed to create new version
cached directory: "
+ << ec.message();
+ continue;
+ }
+ }
+ std::error_code ec;
+ std::filesystem::rename(key_it->path(), key_prefix /
cache_key, ec);
+ if (ec) {
+ LOG(WARNING)
+ << "Failed to move old version cached
directory: " << ec.message();
Review Comment:
If error, I think we should clean all cache to avoid dirty data?
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]