This is an automated email from the ASF dual-hosted git repository. dataroaring pushed a commit to branch branch-3.0 in repository https://gitbox.apache.org/repos/asf/doris.git
commit a4a14cb345ab7b5a681d2c1cd9ddb4d477787177 Author: Luwei <814383...@qq.com> AuthorDate: Wed Aug 28 23:16:37 2024 +0800 [fix](compaction) fix heap-use-after-free caused by compaction sample info resize (#40058) --- be/src/olap/merger.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/be/src/olap/merger.cpp b/be/src/olap/merger.cpp index 87792db93a6..1bba7304638 100644 --- a/be/src/olap/merger.cpp +++ b/be/src/olap/merger.cpp @@ -459,7 +459,10 @@ 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(); @@ -467,10 +470,16 @@ Status Merger::vertical_merge_rowsets(BaseTabletSPtr tablet, ReaderType reader_t 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()); } --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org