Skip to content

Commit

Permalink
avoid init useless DeltaMergeStore (pingcap#5705) (pingcap#7556)
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored May 26, 2023
1 parent 2f9e02c commit daf7c53
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
13 changes: 8 additions & 5 deletions dbms/src/Interpreters/AsynchronousMetrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,14 @@ void AsynchronousMetrics::update()

if (auto dt_storage = std::dynamic_pointer_cast<StorageDeltaMerge>(table); dt_storage)
{
auto stat = dt_storage->getStore()->getStat();
calculateMax(max_dt_stable_oldest_snapshot_lifetime, stat.storage_stable_oldest_snapshot_lifetime);
calculateMax(max_dt_delta_oldest_snapshot_lifetime, stat.storage_delta_oldest_snapshot_lifetime);
calculateMax(max_dt_meta_oldest_snapshot_lifetime, stat.storage_meta_oldest_snapshot_lifetime);
calculateMax(max_dt_background_tasks_length, stat.background_tasks_length);
if (auto store = dt_storage->getStoreIfInited(); store)
{
auto stat = store->getStat();
calculateMax(max_dt_stable_oldest_snapshot_lifetime, stat.storage_stable_oldest_snapshot_lifetime);
calculateMax(max_dt_delta_oldest_snapshot_lifetime, stat.storage_delta_oldest_snapshot_lifetime);
calculateMax(max_dt_meta_oldest_snapshot_lifetime, stat.storage_meta_oldest_snapshot_lifetime);
calculateMax(max_dt_background_tasks_length, stat.background_tasks_length);
}
}
}
}
Expand Down
9 changes: 9 additions & 0 deletions dbms/src/Storages/StorageDeltaMerge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,6 +849,15 @@ void StorageDeltaMerge::deleteRows(const Context & context, size_t delete_rows)
LOG_FMT_ERROR(log, "Rows after delete range not match, expected: {}, got: {}", (total_rows - delete_rows), after_delete_rows);
}

DM::DeltaMergeStorePtr StorageDeltaMerge::getStoreIfInited()
{
if (storeInited())
{
return _store;
}
return nullptr;
}

std::pair<DB::DecodingStorageSchemaSnapshotConstPtr, BlockUPtr> StorageDeltaMerge::getSchemaSnapshotAndBlockForDecoding(const TableStructureLockHolder & table_structure_lock, bool need_block)
{
(void)table_structure_lock;
Expand Down
2 changes: 2 additions & 0 deletions dbms/src/Storages/StorageDeltaMerge.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ class StorageDeltaMerge
return getAndMaybeInitStore();
}

DM::DeltaMergeStorePtr getStoreIfInited();

bool isCommonHandle() const override { return is_common_handle; }

size_t getRowKeyColumnSize() const override { return rowkey_column_size; }
Expand Down

0 comments on commit daf7c53

Please sign in to comment.