Skip to content

Commit

Permalink
[fix](compaction) fix heap-use-after-free caused by compaction sample…
Browse files Browse the repository at this point in the history
… info resize (#40058)
  • Loading branch information
luwei16 authored Aug 28, 2024
1 parent f6d3280 commit bddfd5a
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions be/src/olap/merger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,18 +460,27 @@ Status Merger::vertical_merge_rowsets(BaseTabletSPtr tablet, ReaderType reader_t

vectorized::RowSourcesBuffer row_sources_buf(
tablet->tablet_id(), dst_rowset_writer->context().tablet_path, reader_type);
tablet->sample_infos.resize(column_groups.size(), {0, 0, 0});
{
std::unique_lock<std::mutex> lock(tablet->sample_info_lock);
tablet->sample_infos.resize(column_groups.size(), {0, 0, 0});
}
// compact group one by one
for (auto i = 0; i < column_groups.size(); ++i) {
VLOG_NOTICE << "row source size: " << row_sources_buf.total_size();
bool is_key = (i == 0);
int64_t batch_size = config::compaction_batch_size != -1
? config::compaction_batch_size
: estimate_batch_size(i, tablet, merge_way_num);
RETURN_IF_ERROR(vertical_compact_one_group(
CompactionSampleInfo sample_info;
Status st = vertical_compact_one_group(
tablet, reader_type, tablet_schema, is_key, column_groups[i], &row_sources_buf,
src_rowset_readers, dst_rowset_writer, max_rows_per_segment, stats_output,
key_group_cluster_key_idxes, batch_size, &(tablet->sample_infos[i])));
key_group_cluster_key_idxes, batch_size, &sample_info);
{
std::unique_lock<std::mutex> lock(tablet->sample_info_lock);
tablet->sample_infos[i] = sample_info;
}
RETURN_IF_ERROR(st);
if (is_key) {
RETURN_IF_ERROR(row_sources_buf.flush());
}
Expand Down

0 comments on commit bddfd5a

Please sign in to comment.