Skip to content

Commit

Permalink
[Fix](partial update) Fix partial update info loss when the delete bi…
Browse files Browse the repository at this point in the history
…tmaps of the committed transactions are calculated by the compaction (apache#26556)

a fix for apache#25147
  • Loading branch information
bobhan1 authored and seawinde committed Nov 12, 2023
1 parent dc77df9 commit 78af9c5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
34 changes: 17 additions & 17 deletions be/src/olap/compaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions be/src/olap/txn_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<PartialUpdateInfo> 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));
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions be/src/olap/txn_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<PartialUpdateInfo> 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<PartialUpdateInfo> partial_update_info;
};

using CommitTabletTxnInfoVec = std::vector<CommitTabletTxnInfo>;
Expand Down

0 comments on commit 78af9c5

Please sign in to comment.