Skip to content

Commit

Permalink
[UT] Fix unstable ut (backport #50672) (#50677)
Browse files Browse the repository at this point in the history
Signed-off-by: sevev <[email protected]>
Co-authored-by: zhangqiang <[email protected]>
  • Loading branch information
mergify[bot] and sevev authored Sep 4, 2024
1 parent 7ebcc77 commit 775d482
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions be/src/storage/tablet_updates.h
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,8 @@ class TabletUpdates {
}
}

bool compaction_running() { return _compaction_running; }

void check_for_apply() { _check_for_apply(); }

std::timed_mutex* get_index_lock() { return &_index_lock; }
Expand Down
10 changes: 9 additions & 1 deletion be/test/storage/tablet_updates_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2282,8 +2282,16 @@ void TabletUpdatesTest::test_vertical_compaction(bool enable_persistent_index) {
rs1->rowset_meta()->set_segments_overlap_pb(NONOVERLAPPING);
ASSERT_TRUE(_tablet2->rowset_commit(2, rs1).ok());
std::this_thread::sleep_for(std::chrono::milliseconds(200));
ASSERT_EQ(100, read_tablet(_tablet, 2));
ASSERT_TRUE(_tablet2->updates()->compaction(_compaction_mem_tracker.get()).ok());
std::this_thread::sleep_for(std::chrono::seconds(1));
int32_t count = 0;
while (_tablet->updates()->compaction_running()) {
std::this_thread::sleep_for(std::chrono::seconds(1));
// wait for compaction finish at most 60 seconds
if (++count > 60) {
break;
}
}

ASSERT_EQ(_tablet2->updates()->num_rowsets(), 1);
ASSERT_EQ(_tablet2->updates()->version_history_count(), 3);
Expand Down

0 comments on commit 775d482

Please sign in to comment.