Skip to content
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

[Enhancement] support lake_clear_corrupted_cache option for BE #54216

Merged
merged 1 commit into from
Dec 24, 2024
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
1 change: 1 addition & 0 deletions be/src/common/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -1062,6 +1062,7 @@ CONF_mInt32(lake_pk_index_sst_max_compaction_versions, "100");
// When the ratio of cumulative level to base level is greater than this config, use base merge.
CONF_mDouble(lake_pk_index_cumulative_base_compaction_ratio, "0.1");
CONF_Int32(lake_pk_index_block_cache_limit_percent, "10");
CONF_mBool(lake_clear_corrupted_cache, "true");

CONF_mBool(dependency_librdkafka_debug_enable, "false");

Expand Down
27 changes: 26 additions & 1 deletion be/src/storage/lake/tablet_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include "agent/master_info.h"
#include "common/compiler_util.h"
#include "common/config.h"
#include "fmt/format.h"
#include "fs/fs.h"
#include "fs/fs_util.h"
Expand Down Expand Up @@ -243,7 +244,31 @@ StatusOr<TabletMetadataPtr> TabletManager::load_tablet_metadata(std::shared_ptr<
auto t0 = butil::gettimeofday_us();
auto metadata = std::make_shared<TabletMetadataPB>();
ProtobufFile file(metadata_location, std::move(fs));
RETURN_IF_ERROR(file.load(metadata.get(), fill_cache));
auto s = file.load(metadata.get(), fill_cache);
wyb marked this conversation as resolved.
Show resolved Hide resolved
if (!s.ok()) {
if (s.is_corruption() && config::lake_clear_corrupted_cache) {
starrocks-xupeng marked this conversation as resolved.
Show resolved Hide resolved
auto tmp_fs = FileSystem::CreateSharedFromString(metadata_location);
if (!tmp_fs.ok()) {
LOG(WARNING) << "fail to get file system to clear corrupted cache for " << metadata_location
<< ", error: " << tmp_fs.status();
return s;
}
auto drop_status = (*tmp_fs)->drop_local_cache(metadata_location);
if (drop_status.ok()) {
LOG(INFO) << "clear corrupted cache for " << metadata_location;
// reset metadata
metadata = std::make_shared<TabletMetadataPB>();
// read again
RETURN_IF_ERROR(file.load(metadata.get(), fill_cache));
} else {
LOG(WARNING) << "clear corrupted cache for " << metadata_location << " failed, "
<< "error: " << drop_status;
return s; // return error so load tablet meta can be retried
}
} else {
return s;
}
}
g_get_tablet_metadata_latency << (butil::gettimeofday_us() - t0);
return std::move(metadata);
}
Expand Down
Loading