From 78af9c50e0f355a5c96570ca70f3f8f5c54e6c96 Mon Sep 17 00:00:00 2001 From: bobhan1 Date: Wed, 8 Nov 2023 19:56:31 +0800 Subject: [PATCH] [Fix](partial update) Fix partial update info loss when the delete bitmaps of the committed transactions are calculated by the compaction (#26556) a fix for #25147 --- be/src/olap/compaction.cpp | 34 +++++++++++++++++----------------- be/src/olap/txn_manager.cpp | 7 +++++-- be/src/olap/txn_manager.h | 7 +++++-- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/be/src/olap/compaction.cpp b/be/src/olap/compaction.cpp index b025555166a391..415be6bb0af8a5 100644 --- a/be/src/olap/compaction.cpp +++ b/be/src/olap/compaction.cpp @@ -718,24 +718,24 @@ Status Compaction::modify_rowsets(const Merger::Statistics* stats) { // Therefore, we need to check if every committed rowset has calculated delete bitmap for // all compaction input rowsets. continue; - } else { - DeleteBitmap txn_output_delete_bitmap(_tablet->tablet_id()); - _tablet->calc_compaction_output_rowset_delete_bitmap( - _input_rowsets, _rowid_conversion, 0, UINT64_MAX, &missed_rows, - &location_map, *it.delete_bitmap.get(), &txn_output_delete_bitmap); - if (config::enable_merge_on_write_correctness_check) { - RowsetIdUnorderedSet rowsetids; - rowsetids.insert(_output_rowset->rowset_id()); - _tablet->add_sentinel_mark_to_delete_bitmap(&txn_output_delete_bitmap, - rowsetids); - } - it.delete_bitmap->merge(txn_output_delete_bitmap); - // Step3: write back updated delete bitmap and tablet info. - it.rowset_ids.insert(_output_rowset->rowset_id()); - StorageEngine::instance()->txn_manager()->set_txn_related_delete_bitmap( - it.partition_id, it.transaction_id, _tablet->tablet_id(), - _tablet->tablet_uid(), true, it.delete_bitmap, it.rowset_ids, nullptr); } + DeleteBitmap txn_output_delete_bitmap(_tablet->tablet_id()); + _tablet->calc_compaction_output_rowset_delete_bitmap( + _input_rowsets, _rowid_conversion, 0, UINT64_MAX, &missed_rows, + &location_map, *it.delete_bitmap.get(), &txn_output_delete_bitmap); + if (config::enable_merge_on_write_correctness_check) { + RowsetIdUnorderedSet rowsetids; + rowsetids.insert(_output_rowset->rowset_id()); + _tablet->add_sentinel_mark_to_delete_bitmap(&txn_output_delete_bitmap, + rowsetids); + } + it.delete_bitmap->merge(txn_output_delete_bitmap); + // Step3: write back updated delete bitmap and tablet info. + it.rowset_ids.insert(_output_rowset->rowset_id()); + StorageEngine::instance()->txn_manager()->set_txn_related_delete_bitmap( + it.partition_id, it.transaction_id, _tablet->tablet_id(), + _tablet->tablet_uid(), true, it.delete_bitmap, it.rowset_ids, + it.partial_update_info); } // Convert the delete bitmap of the input rowsets to output rowset for diff --git a/be/src/olap/txn_manager.cpp b/be/src/olap/txn_manager.cpp index af6b0d672359d4..4198d7563260bb 100644 --- a/be/src/olap/txn_manager.cpp +++ b/be/src/olap/txn_manager.cpp @@ -675,11 +675,14 @@ void TxnManager::get_all_commit_tablet_txn_info_by_tablet( const RowsetSharedPtr& rowset = tablet_load_it->second.rowset; const DeleteBitmapPtr& delete_bitmap = tablet_load_it->second.delete_bitmap; const RowsetIdUnorderedSet& rowset_ids = tablet_load_it->second.rowset_ids; + const std::shared_ptr partial_update_info = + tablet_load_it->second.partial_update_info; if (!rowset || !delete_bitmap) { continue; } - commit_tablet_txn_info_vec->push_back(CommitTabletTxnInfo( - partition_id, transaction_id, delete_bitmap, rowset_ids)); + commit_tablet_txn_info_vec->push_back( + CommitTabletTxnInfo(partition_id, transaction_id, delete_bitmap, rowset_ids, + partial_update_info)); } } } diff --git a/be/src/olap/txn_manager.h b/be/src/olap/txn_manager.h index b5a1db0b46ef6e..9fa146710c0a01 100644 --- a/be/src/olap/txn_manager.h +++ b/be/src/olap/txn_manager.h @@ -101,15 +101,18 @@ struct TabletTxnInfo { struct CommitTabletTxnInfo { CommitTabletTxnInfo(TPartitionId partition_id, TTransactionId transaction_id, - DeleteBitmapPtr delete_bitmap, RowsetIdUnorderedSet rowset_ids) + DeleteBitmapPtr delete_bitmap, RowsetIdUnorderedSet rowset_ids, + std::shared_ptr partial_update_info) : transaction_id(transaction_id), partition_id(partition_id), delete_bitmap(delete_bitmap), - rowset_ids(rowset_ids) {} + rowset_ids(rowset_ids), + partial_update_info(partial_update_info) {} TTransactionId transaction_id; TPartitionId partition_id; DeleteBitmapPtr delete_bitmap; RowsetIdUnorderedSet rowset_ids; + std::shared_ptr partial_update_info; }; using CommitTabletTxnInfoVec = std::vector;