Skip to content

Commit

Permalink
[fix](merge-on-write) fix that the version of delete bitmap is incorr…
Browse files Browse the repository at this point in the history
…ect when calculate delete bitmap between segments (apache#17095)

Different version numbers are used to calculate the delete bitmap between segments and rowsets, resulting in the failure of the last update of the delete bitmap.
  • Loading branch information
liaoxin01 authored Feb 27, 2023
1 parent cec3d19 commit d5b1d34
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
14 changes: 6 additions & 8 deletions be/src/olap/tablet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2410,15 +2410,14 @@ Status Tablet::calc_delete_bitmap(RowsetId rowset_id,
RowLocation loc;
// first check if exist in pre segment
if (check_pre_segments) {
auto st = _check_pk_in_pre_segments(rowset_id, pre_segments, key, dummy_version,
delete_bitmap, &loc);
auto st = _check_pk_in_pre_segments(rowset_id, pre_segments, key, delete_bitmap,
&loc);
if (st.ok()) {
delete_bitmap->add({rowset_id, loc.segment_id, dummy_version.first},
loc.row_id);
delete_bitmap->add({rowset_id, loc.segment_id, 0}, loc.row_id);
++row_id;
continue;
} else if (st.is<ALREADY_EXIST>()) {
delete_bitmap->add({rowset_id, seg->id(), dummy_version.first}, row_id);
delete_bitmap->add({rowset_id, seg->id(), 0}, row_id);
++row_id;
continue;
}
Expand Down Expand Up @@ -2467,15 +2466,14 @@ Status Tablet::calc_delete_bitmap(RowsetId rowset_id,

Status Tablet::_check_pk_in_pre_segments(
RowsetId rowset_id, const std::vector<segment_v2::SegmentSharedPtr>& pre_segments,
const Slice& key, const Version& version, DeleteBitmapPtr delete_bitmap, RowLocation* loc) {
const Slice& key, DeleteBitmapPtr delete_bitmap, RowLocation* loc) {
for (auto it = pre_segments.rbegin(); it != pre_segments.rend(); ++it) {
auto st = (*it)->lookup_row_key(key, loc);
CHECK(st.ok() || st.is<NOT_FOUND>() || st.is<ALREADY_EXIST>());
if (st.is<NOT_FOUND>()) {
continue;
} else if (st.ok() && _schema->has_sequence_col() &&
delete_bitmap->contains({rowset_id, loc->segment_id, version.first},
loc->row_id)) {
delete_bitmap->contains({rowset_id, loc->segment_id, 0}, loc->row_id)) {
// if has sequence col, we continue to compare the sequence_id of
// all segments, util we find an existing key.
continue;
Expand Down
4 changes: 2 additions & 2 deletions be/src/olap/tablet.h
Original file line number Diff line number Diff line change
Expand Up @@ -442,8 +442,8 @@ class Tablet : public BaseTablet {

Status _check_pk_in_pre_segments(RowsetId rowset_id,
const std::vector<segment_v2::SegmentSharedPtr>& pre_segments,
const Slice& key, const Version& version,
DeleteBitmapPtr delete_bitmap, RowLocation* loc);
const Slice& key, DeleteBitmapPtr delete_bitmap,
RowLocation* loc);
void _rowset_ids_difference(const RowsetIdUnorderedSet& cur, const RowsetIdUnorderedSet& pre,
RowsetIdUnorderedSet* to_add, RowsetIdUnorderedSet* to_del);
Status _load_rowset_segments(const RowsetSharedPtr& rowset,
Expand Down

0 comments on commit d5b1d34

Please sign in to comment.