Skip to content

Commit

Permalink
[fix](meta-service) Avoid rowset meta exceeds 2G result in protobuf f…
Browse files Browse the repository at this point in the history
…atal
  • Loading branch information
TangSiyang2001 committed Nov 29, 2024
1 parent 1ffecfd commit 001b254
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 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()) {
code = MetaServiceCode::PROTOBUF_PARSE_ERR;
msg = "rowset meta exceeded 2G, unable to deserialize";
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";
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

0 comments on commit 001b254

Please sign in to comment.