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](meta-service) Avoid rowset meta exceeds 2G result in protobuf fatal #44780

Merged
merged 5 commits into from
Dec 9, 2024
Merged
Changes from 1 commit
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
15 changes: 12 additions & 3 deletions cloud/src/meta-service/meta_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1310,15 +1310,24 @@ void internal_get_rowset(Transaction* txn, int64_t start, int64_t end,

while (it->has_next()) {
auto [k, v] = it->next();
auto rs = response->add_rowset_meta();
auto* rs = response->add_rowset_meta();
auto byte_size = rs->ByteSizeLong();
if (byte_size + v.size() > std::numeric_limits<int32_t>::max()) {
TangSiyang2001 marked this conversation as resolved.
Show resolved Hide resolved
code = MetaServiceCode::PROTOBUF_PARSE_ERR;
msg = "rowset meta exceeded 2G, unable to serialize";
LOG(WARNING) << msg << " key=" << hex(k);
return;
}
if (!rs->ParseFromArray(v.data(), v.size())) {
code = MetaServiceCode::PROTOBUF_PARSE_ERR;
msg = "malformed rowset meta, unable to deserialize";
msg = "malformed rowset meta, unable to serialize";
LOG(WARNING) << msg << " key=" << hex(k);
return;
}
++num_rowsets;
if (!it->has_next()) key0 = k;
if (!it->has_next()) {
key0 = k;
}
}
key0.push_back('\x00'); // Update to next smallest key for iteration
} while (it->more());
Expand Down
Loading