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

[fix](cloud-balance) use right file size instead of block size #38939

Merged
merged 3 commits into from
Aug 7, 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/cloud/cloud_internal_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ void CloudInternalServiceImpl::get_file_cache_meta_by_tablet_id(
meta->set_rowset_id(rowset_id);
meta->set_segment_id(segment_id);
meta->set_file_name(file_name);
meta->set_file_size(rowset->rowset_meta()->segment_file_size(segment_id));
meta->set_offset(std::get<0>(tuple));
meta->set_size(std::get<1>(tuple));
meta->set_cache_type(cache_type_to_pb(std::get<2>(tuple)));
Expand Down
3 changes: 2 additions & 1 deletion be/src/io/cache/block_file_cache_downloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,8 @@ void FileCacheBlockDownloader::download_file_cache_block(
DownloadFileMeta download_meta {
.path = storage_resource.value()->remote_segment_path(*find_it->second,
meta.segment_id()),
.file_size = meta.offset() + meta.size(), // To avoid trigger get file size IO
.file_size = meta.has_file_size() ? meta.file_size()
: -1, // To avoid trigger get file size IO
dataroaring marked this conversation as resolved.
Show resolved Hide resolved
.offset = meta.offset(),
.download_size = meta.size(),
.file_system = storage_resource.value()->fs,
Expand Down
18 changes: 10 additions & 8 deletions be/src/olap/rowset/segment_v2/segment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,10 @@ Status Segment::_parse_footer(SegmentFooterPB* footer) {
DCHECK_EQ(bytes_read, 12);

if (memcmp(fixed_buf + 8, k_segment_magic, k_segment_magic_length) != 0) {
return Status::Corruption("Bad segment file {}: magic number not match, cache_key: {}",
_file_reader->path().native(),
file_cache_key_str(_file_reader->path().native()));
return Status::Corruption(
"Bad segment file {}: file_size: {}, magic number not match, cache_key: {}",
_file_reader->path().native(), file_size,
file_cache_key_str(_file_reader->path().native()));
}

// read footer PB
Expand All @@ -339,17 +340,18 @@ Status Segment::_parse_footer(SegmentFooterPB* footer) {
uint32_t actual_checksum = crc32c::Value(footer_buf.data(), footer_buf.size());
if (actual_checksum != expect_checksum) {
return Status::Corruption(
"Bad segment file {}: footer checksum not match, actual={} vs expect={}, "
"cache_key: {}",
_file_reader->path().native(), actual_checksum, expect_checksum,
"Bad segment file {}: file_size = {}, footer checksum not match, actual={} "
"vs expect={}, cache_key: {}",
_file_reader->path().native(), file_size, actual_checksum, expect_checksum,
file_cache_key_str(_file_reader->path().native()));
}

// deserialize footer PB
if (!footer->ParseFromString(footer_buf)) {
return Status::Corruption(
"Bad segment file {}: failed to parse SegmentFooterPB, cache_key: ",
_file_reader->path().native(), file_cache_key_str(_file_reader->path().native()));
"Bad segment file {}: file_size = {}, failed to parse SegmentFooterPB, cache_key: ",
_file_reader->path().native(), file_size,
file_cache_key_str(_file_reader->path().native()));
}
return Status::OK();
}
Expand Down
1 change: 1 addition & 0 deletions gensrc/proto/internal_service.proto
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,7 @@ message FileCacheBlockMeta {
required int64 size = 6;
required FileCacheType cache_type = 7;
required int64 expiration_time = 8;
optional int64 file_size = 9;
}

message PGetFileCacheMetaResponse {
Expand Down
Loading