Skip to content

Commit

Permalink
*: Fix max snapshot lifetime is not shown on Grafana (#8102) (#8104)
Browse files Browse the repository at this point in the history
close #7713
  • Loading branch information
ti-chi-bot authored Sep 21, 2023
1 parent 65a9f86 commit e9e4e55
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 7 deletions.
54 changes: 48 additions & 6 deletions dbms/src/Interpreters/AsynchronousMetrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <Storages/DeltaMerge/StoragePool.h>
#include <Storages/MarkCache.h>
#include <Storages/Page/FileUsage.h>
#include <Storages/Page/PageConstants.h>
#include <Storages/Page/PageStorage.h>
#include <Storages/Page/V3/Universal/UniversalPageStorageService.h>
#include <Storages/StorageDeltaMerge.h>
Expand Down Expand Up @@ -236,18 +237,59 @@ void AsynchronousMetrics::update()
if (auto store = dt_storage->getStoreIfInited(); store)
{
auto stat = store->getStoreStats();
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);
if (context.getPageStorageRunMode() == PageStorageRunMode::ONLY_V2)
{
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);
}
}
}
}

set("MaxDTStableOldestSnapshotLifetime", max_dt_stable_oldest_snapshot_lifetime);
set("MaxDTDeltaOldestSnapshotLifetime", max_dt_delta_oldest_snapshot_lifetime);
set("MaxDTMetaOldestSnapshotLifetime", max_dt_meta_oldest_snapshot_lifetime);
switch (context.getPageStorageRunMode())
{
case PageStorageRunMode::ONLY_V2:
{
set("MaxDTStableOldestSnapshotLifetime", max_dt_stable_oldest_snapshot_lifetime);
set("MaxDTDeltaOldestSnapshotLifetime", max_dt_delta_oldest_snapshot_lifetime);
set("MaxDTMetaOldestSnapshotLifetime", max_dt_meta_oldest_snapshot_lifetime);
break;
}
case PageStorageRunMode::ONLY_V3:
case PageStorageRunMode::MIX_MODE:
{
if (auto global_storage_pool = context.getGlobalStoragePool(); global_storage_pool)
{
const auto log_snap_stat = global_storage_pool->log_storage->getSnapshotsStat();
const auto meta_snap_stat = global_storage_pool->meta_storage->getSnapshotsStat();
const auto data_snap_stat = global_storage_pool->data_storage->getSnapshotsStat();
set("MaxDTDeltaOldestSnapshotLifetime", log_snap_stat.longest_living_seconds);
set("MaxDTMetaOldestSnapshotLifetime", meta_snap_stat.longest_living_seconds);
set("MaxDTStableOldestSnapshotLifetime", data_snap_stat.longest_living_seconds);
}
break;
}
case PageStorageRunMode::UNI_PS:
{
if (auto uni_ps = context.tryGetWriteNodePageStorage(); uni_ps != nullptr)
{
// Only set delta snapshot lifetime when UniPS is enabled
const auto snap_stat = uni_ps->getSnapshotsStat();
set("MaxDTDeltaOldestSnapshotLifetime", snap_stat.longest_living_seconds);
}
break;
}
}

set("MaxDTBackgroundTasksLength", max_dt_background_tasks_length);
}

Expand Down
5 changes: 4 additions & 1 deletion dbms/src/Storages/Transaction/TMTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ static SchemaSyncerPtr createSchemaSyncer(bool exist_pd_addr, bool for_unit_test
std::make_shared<TiDBSchemaSyncer</*mock_getter*/ true, /*mock_mapper*/ false>>(cluster));
}

TMTContext::TMTContext(Context & context_, const TiFlashRaftConfig & raft_config, const pingcap::ClusterConfig & cluster_config)
TMTContext::TMTContext(
Context & context_,
const TiFlashRaftConfig & raft_config,
const pingcap::ClusterConfig & cluster_config)
: context(context_)
, kvstore(context_.getSharedContextDisagg()->isDisaggregatedComputeMode() && context_.getSharedContextDisagg()->use_autoscaler ? nullptr : std::make_shared<KVStore>(context))
, region_table(context)
Expand Down

0 comments on commit e9e4e55

Please sign in to comment.