Skip to content

Commit

Permalink
[fix](cloud-balance) use right file size instead of block size (apach…
Browse files Browse the repository at this point in the history
…e#38939)

introduced by apache#34191
  • Loading branch information
dataroaring authored and wyxxxcat committed Aug 14, 2024
1 parent 82cb8c3 commit 459170f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
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
.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 @@ -805,6 +805,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

0 comments on commit 459170f

Please sign in to comment.