This is an automated email from the ASF dual-hosted git repository. zhangchen pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push: new f842067354 [fix](merge-on-write) fix duplicate keys occur when be restart (#22437) f842067354 is described below commit f8420673543ab668d750ad9723050ed3e358d9c8 Author: Xin Liao <liaoxin...@126.com> AuthorDate: Tue Aug 1 14:07:04 2023 +0800 [fix](merge-on-write) fix duplicate keys occur when be restart (#22437) For mow table, delete bitmap of stale rowsets has not been persisted. When be restart, duplicate keys will occur if read stale rowsets. Therefore, for the mow table, we do not allow reading the stale rowsets. Although this may result in VERSION_ALREADY_MERGED error when query after be restart, its probability of occurrence is relatively low. --- be/src/olap/tablet_meta.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/be/src/olap/tablet_meta.cpp b/be/src/olap/tablet_meta.cpp index 5fcfadffff..01d206ebe9 100644 --- a/be/src/olap/tablet_meta.cpp +++ b/be/src/olap/tablet_meta.cpp @@ -507,6 +507,10 @@ void TabletMeta::init_from_pb(const TabletMetaPB& tablet_meta_pb) { // init _schema _schema->init_from_pb(tablet_meta_pb.schema()); + if (tablet_meta_pb.has_enable_unique_key_merge_on_write()) { + _enable_unique_key_merge_on_write = tablet_meta_pb.enable_unique_key_merge_on_write(); + } + // init _rs_metas for (auto& it : tablet_meta_pb.rs_metas()) { RowsetMetaSharedPtr rs_meta(new RowsetMeta()); @@ -514,10 +518,15 @@ void TabletMeta::init_from_pb(const TabletMetaPB& tablet_meta_pb) { _rs_metas.push_back(std::move(rs_meta)); } - for (auto& it : tablet_meta_pb.stale_rs_metas()) { - RowsetMetaSharedPtr rs_meta(new RowsetMeta()); - rs_meta->init_from_pb(it); - _stale_rs_metas.push_back(std::move(rs_meta)); + // For mow table, delete bitmap of stale rowsets has not been persisted. + // When be restart, query should not read the stale rowset, otherwise duplicate keys + // will be read out. Therefore, we don't add them to _stale_rs_meta for mow table. + if (!_enable_unique_key_merge_on_write) { + for (auto& it : tablet_meta_pb.stale_rs_metas()) { + RowsetMetaSharedPtr rs_meta(new RowsetMeta()); + rs_meta->init_from_pb(it); + _stale_rs_metas.push_back(std::move(rs_meta)); + } } if (tablet_meta_pb.has_in_restore_mode()) { @@ -533,10 +542,6 @@ void TabletMeta::init_from_pb(const TabletMetaPB& tablet_meta_pb) { _cooldown_meta_id = tablet_meta_pb.cooldown_meta_id(); } - if (tablet_meta_pb.has_enable_unique_key_merge_on_write()) { - _enable_unique_key_merge_on_write = tablet_meta_pb.enable_unique_key_merge_on_write(); - } - if (tablet_meta_pb.has_delete_bitmap()) { int rst_ids_size = tablet_meta_pb.delete_bitmap().rowset_ids_size(); int seg_ids_size = tablet_meta_pb.delete_bitmap().segment_ids_size(); --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org