Skip to content

Commit

Permalink
add ut
Browse files Browse the repository at this point in the history
Signed-off-by: sevev <[email protected]>
  • Loading branch information
sevev committed Dec 4, 2024
1 parent 955bfef commit 3019287
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
6 changes: 6 additions & 0 deletions be/src/storage/tablet_updates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@ DEFINE_FAIL_POINT(tablet_apply_cache_del_vec_failed);
DEFINE_FAIL_POINT(tablet_apply_tablet_drop);
DEFINE_FAIL_POINT(tablet_apply_load_compaction_state_failed);
DEFINE_FAIL_POINT(tablet_apply_load_segments_failed);
DEFINE_FAIL_POINT(tablet_delvec_inconsistent);

void TabletUpdates::do_apply() {
SCOPED_THREAD_LOCAL_CHECK_MEM_LIMIT_SETTER(true);
Expand Down Expand Up @@ -1615,6 +1616,11 @@ Status TabletUpdates::_apply_normal_rowset_commit(const EditVersionInfo& version
size_t cur_old = old_del_vec->cardinality();
size_t cur_add = new_delete.second.size();
size_t cur_new = new_del_vecs[idx].second->cardinality();
FAIL_POINT_TRIGGER_EXECUTE(tablet_delvec_inconsistent, {
cur_old = 0;
cur_add = 1;
cur_new = 0;
});
if (cur_old + cur_add != cur_new) {
// should not happen, data inconsistent
string msg = strings::Substitute(
Expand Down
22 changes: 20 additions & 2 deletions be/test/storage/tablet_updates_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3608,9 +3608,27 @@ TEST_F(TabletUpdatesTest, test_normal_apply_retry) {

// 14. get del_vec failed
test_fail_point("tablet_apply_get_del_vec_failed", 15, N / 2);
}

TEST_F(TabletUpdatesTest, test_column_mode_partial_update_apply_retry) {}
// 15. delvec inconsistent
{
// Enable fail point
trigger_mode.set_mode(FailPointTriggerModeType::ENABLE);
auto fp = starrocks::failpoint::FailPointRegistry::GetInstance()->get("tablet_delvec_inconsistent");
fp->setMode(trigger_mode);

// Create and commit rowset
auto rs = create_rowset(_tablet, keys, &deletes);
ASSERT_TRUE(_tablet->rowset_commit(16, rs).ok());
ASSERT_EQ(16, _tablet->updates()->max_version());

// Wait for a short duration and check error state
std::this_thread::sleep_for(std::chrono::milliseconds(200));
ASSERT_TRUE(_tablet->updates()->is_error());

trigger_mode.set_mode(FailPointTriggerModeType::DISABLE);
fp->setMode(trigger_mode);
}
}

TEST_F(TabletUpdatesTest, test_compaction_apply_retry) {
config::retry_apply_interval_second = 1;
Expand Down

0 comments on commit 3019287

Please sign in to comment.