Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[fix](merge-on-write) fix duplicate keys occur when be restart #22437

Merged
merged 1 commit into from
Aug 1, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions be/src/olap/tablet_meta.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,17 +507,26 @@ 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());
rs_meta->init_from_pb(it);
_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()) {
Expand All @@ -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();
Expand Down
Loading