Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
lidezhu committed Feb 14, 2023
1 parent 6a81b9a commit 012df3d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions dbms/src/Interpreters/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1650,6 +1650,7 @@ bool Context::initializeGlobalStoragePoolIfNeed(const PathPool & path_pool)
{
// GlobalStoragePool may be initialized many times in some test cases for restore.
LOG_WARNING(shared->log, "GlobalStoragePool has already been initialized.");
shared->global_storage_pool->shutdown();
}
CurrentMetrics::set(CurrentMetrics::GlobalStorageRunMode, static_cast<UInt8>(shared->storage_run_mode));
if (shared->storage_run_mode == PageStorageRunMode::MIX_MODE || shared->storage_run_mode == PageStorageRunMode::ONLY_V3)
Expand Down
9 changes: 7 additions & 2 deletions dbms/src/Storages/DeltaMerge/tests/gtest_dm_minmax_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Attr pkAttr()
return Attr{col.name, col.id, col.type};
}


bool checkMatch(
const String & test_case,
Context & context,
Expand All @@ -87,6 +88,11 @@ bool checkMatch(
bool check_pk = false)
{
String name = "DMMinMaxIndexTest_" + test_case;
// We cannot restore tables with the same table id multiple times in a single run.
// Because we don't update max_page_id for PS instance at run time.
// And when restoring table, it will use the max_page_id from PS as the start point for allocating page id.
// So if we restore the same table multiple times in a single run, it may write different data using the same page id.
static int next_table_id = 100;

auto clean_up = [&]() {
context.dropMinMaxIndexCache();
Expand All @@ -109,13 +115,12 @@ bool checkMatch(
Block block = genBlock(header, block_tuples);

// max page id is only updated at restart, so we need recreate page v3 before recreate table
context.initializeGlobalStoragePoolIfNeed(context.getPathPool());
DeltaMergeStorePtr store = std::make_shared<DeltaMergeStore>(
context,
false,
"test_database",
name,
/*table_id*/ 100,
/*table_id*/ next_table_id++,
true,
table_columns,
getExtraHandleColumnDefine(is_common_handle),
Expand Down

0 comments on commit 012df3d

Please sign in to comment.