Skip to content

Commit

Permalink
[BugFix] Fix pindex read/write confilict when enable pindex rebuild i…
Browse files Browse the repository at this point in the history
…n compaction (StarRocks#37197)

Why I'm doing:

This bug is introduced by this pr(StarRocks#36819), we will rebuild pindex if we pick all rowsets to do compaction. But in rebuild pindex, we try to reset pindex but doesn't hold the lock which may cause read/write conflict between compaction and data ingestion.

What I'm doing:

Hold the primary index lock when we reset primary index.

Signed-off-by: zhangqiang <[email protected]>
  • Loading branch information
sevev committed Dec 18, 2023
1 parent 3f669b6 commit 4409c58
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions be/src/storage/primary_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,7 @@ Status PrimaryIndex::major_compaction(Tablet* tablet) {
}

Status PrimaryIndex::reset(Tablet* tablet, EditVersion version, PersistentIndexMetaPB* index_meta) {
std::lock_guard<std::mutex> lg(_lock);
_table_id = tablet->belonged_table_id();
_tablet_id = tablet->tablet_id();
const TabletSchema& tablet_schema = tablet->tablet_schema();
Expand Down

0 comments on commit 4409c58

Please sign in to comment.