This is an automated email from the ASF dual-hosted git repository. morningman pushed a commit to branch branch-1.2-lts in repository https://gitbox.apache.org/repos/asf/doris.git
commit 3a78df799de821d0a83c70989b170eea4e6a0307 Author: xueweizhang <zxw520bl...@163.com> AuthorDate: Fri Mar 10 07:55:00 2023 +0800 [fix](merge-on-write) when if publish and be down, need recalc delete bitmap for MoW (#17617) * (merge-on-write) when if publish and be down, need recalc delete bitmap for MoW Signed-off-by: nextdreamblue <zxw520bl...@163.com> * fix code Signed-off-by: nextdreamblue <zxw520bl...@163.com> --------- Signed-off-by: nextdreamblue <zxw520bl...@163.com> --- be/src/olap/tablet.cpp | 27 +++++++++++++++------------ be/src/olap/txn_manager.cpp | 9 +++++++++ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/be/src/olap/tablet.cpp b/be/src/olap/tablet.cpp index e3670d1129..3c6dfdfdf3 100644 --- a/be/src/olap/tablet.cpp +++ b/be/src/olap/tablet.cpp @@ -2201,18 +2201,21 @@ Status Tablet::update_delete_bitmap(const RowsetSharedPtr& rowset, const TabletT delete_bitmap, cur_version - 1, true)); // Check the delete_bitmap correctness. - DeleteBitmap rs_bm(tablet_id()); - delete_bitmap->subset({rowset->rowset_id(), 0, 0}, {rowset->rowset_id(), UINT32_MAX, INT64_MAX}, - &rs_bm); - auto num_rows = rowset->num_rows(); - auto bitmap_cardinality = rs_bm.cardinality(); - std::string err_msg = fmt::format( - "The delete bitmap of unique key table may not correct, expect num unique keys: {}, " - "now the num_rows: {}, delete bitmap cardinality: {}, num sgements: {}", - load_info->num_keys, num_rows, bitmap_cardinality, rowset->num_segments()); - DCHECK_EQ(load_info->num_keys, num_rows - bitmap_cardinality) << err_msg; - if (load_info->num_keys != num_rows - bitmap_cardinality) { - return Status::InternalError(err_msg); + if (load_info->num_keys != 0) { + DeleteBitmap rs_bm(tablet_id()); + delete_bitmap->subset({rowset->rowset_id(), 0, 0}, + {rowset->rowset_id(), UINT32_MAX, INT64_MAX}, &rs_bm); + auto num_rows = rowset->num_rows(); + auto bitmap_cardinality = rs_bm.cardinality(); + std::string err_msg = fmt::format( + "The delete bitmap of unique key table may not correct, expect num unique keys:" + "{}, " + "now the num_rows: {}, delete bitmap cardinality: {}, num sgements: {}", + load_info->num_keys, num_rows, bitmap_cardinality, rowset->num_segments()); + DCHECK_EQ(load_info->num_keys, num_rows - bitmap_cardinality) << err_msg; + if (load_info->num_keys != num_rows - bitmap_cardinality) { + return Status::InternalError(err_msg); + } } // update version without write lock, compaction and publish_txn diff --git a/be/src/olap/txn_manager.cpp b/be/src/olap/txn_manager.cpp index 5d3daef7d5..e953ed87e2 100644 --- a/be/src/olap/txn_manager.cpp +++ b/be/src/olap/txn_manager.cpp @@ -269,6 +269,15 @@ Status TxnManager::commit_txn(OlapMeta* meta, TPartitionId partition_id, { std::lock_guard<std::shared_mutex> wrlock(_get_txn_map_lock(transaction_id)); TabletTxnInfo load_info(load_id, rowset_ptr); + if (is_recovery) { + TabletSharedPtr tablet = StorageEngine::instance()->tablet_manager()->get_tablet( + tablet_info.tablet_id, tablet_info.tablet_uid); + if (tablet != nullptr && tablet->enable_unique_key_merge_on_write()) { + load_info.unique_key_merge_on_write = true; + load_info.delete_bitmap.reset(new DeleteBitmap(tablet->tablet_id())); + load_info.num_keys = 0; + } + } txn_tablet_map_t& txn_tablet_map = _get_txn_tablet_map(transaction_id); txn_tablet_map[key][tablet_info] = load_info; _insert_txn_partition_map_unlocked(transaction_id, partition_id); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org