Skip to content

Commit

Permalink
add metrics for storage pool run mode
Browse files Browse the repository at this point in the history
Signed-off-by: hehechen <[email protected]>
  • Loading branch information
hehechen committed May 12, 2022
1 parent efc93ad commit 3434d4f
Show file tree
Hide file tree
Showing 6 changed files with 314 additions and 3 deletions.
7 changes: 6 additions & 1 deletion dbms/src/Common/CurrentMetrics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,12 @@
M(IOLimiterPendingBgWriteReq) \
M(IOLimiterPendingFgWriteReq) \
M(IOLimiterPendingBgReadReq) \
M(IOLimiterPendingFgReadReq)
M(IOLimiterPendingFgReadReq) \
M(StoragePoolV2Only) \
M(StoragePoolV3Only) \
M(StoragePoolMixMode) \
M(RegionPersisterRunMode) \
M(GlobalStorageRunMode)

namespace CurrentMetrics
{
Expand Down
3 changes: 2 additions & 1 deletion dbms/src/Interpreters/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ namespace CurrentMetrics
{
extern const Metric ContextLockWait;
extern const Metric MemoryTrackingForMerges;
extern const Metric GlobalStorageRunMode;
} // namespace CurrentMetrics


Expand Down Expand Up @@ -1654,7 +1655,7 @@ bool Context::initializeGlobalStoragePoolIfNeed(const PathPool & path_pool)
// Also won't remove it from ~GlobalStoragePool()
throw Exception("GlobalStoragePool has already been initialized.", ErrorCodes::LOGICAL_ERROR);
}

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)
{
try
Expand Down
16 changes: 15 additions & 1 deletion dbms/src/Storages/DeltaMerge/StoragePool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,22 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include <Common/CurrentMetrics.h>
#include <Common/FailPoint.h>
#include <Interpreters/Context.h>
#include <Interpreters/Settings.h>
#include <Storages/DeltaMerge/StoragePool.h>
#include <Storages/Page/ConfigSettings.h>
#include <fmt/format.h>


namespace CurrentMetrics
{
extern const Metric StoragePoolV2Only;
extern const Metric StoragePoolV3Only;
extern const Metric StoragePoolMixMode;
} // namespace CurrentMetrics

namespace DB
{
namespace ErrorCodes
Expand All @@ -30,6 +39,7 @@ namespace FailPoints
{
extern const char force_set_dtfile_exist_when_acquire_id[];
} // namespace FailPoints

namespace DM
{
enum class StorageType
Expand Down Expand Up @@ -159,6 +169,7 @@ StoragePool::StoragePool(Context & global_ctx, NamespaceId ns_id_, StoragePathPo
, run_mode(global_ctx.getPageStorageRunMode())
, ns_id(ns_id_)
, global_context(global_ctx)
, storage_pool_metrics(CurrentMetrics::StoragePoolV3Only, 0)
{
const auto & global_storage_pool = global_context.getGlobalStoragePool();
switch (run_mode)
Expand Down Expand Up @@ -200,7 +211,6 @@ StoragePool::StoragePool(Context & global_ctx, NamespaceId ns_id_, StoragePathPo
log_storage_writer = std::make_shared<PageWriter>(run_mode, /*storage_v2_*/ nullptr, log_storage_v3);
data_storage_writer = std::make_shared<PageWriter>(run_mode, /*storage_v2_*/ nullptr, data_storage_v3);
meta_storage_writer = std::make_shared<PageWriter>(run_mode, /*storage_v2_*/ nullptr, meta_storage_v3);

break;
}
case PageStorageRunMode::MIX_MODE:
Expand Down Expand Up @@ -257,6 +267,7 @@ PageStorageRunMode StoragePool::restore()
max_data_page_id = data_max_ids[0];
max_meta_page_id = meta_max_ids[0];

storage_pool_metrics = CurrentMetrics::Increment{CurrentMetrics::StoragePoolV2Only};
break;
}
case PageStorageRunMode::ONLY_V3:
Expand All @@ -265,6 +276,7 @@ PageStorageRunMode StoragePool::restore()
max_data_page_id = global_storage_pool->getDataMaxId(ns_id);
max_meta_page_id = global_storage_pool->getMetaMaxId(ns_id);

storage_pool_metrics = CurrentMetrics::Increment{CurrentMetrics::StoragePoolV3Only};
break;
}
case PageStorageRunMode::MIX_MODE:
Expand Down Expand Up @@ -304,12 +316,14 @@ PageStorageRunMode StoragePool::restore()
max_meta_page_id = global_storage_pool->getMetaMaxId(ns_id);

run_mode = PageStorageRunMode::ONLY_V3;
storage_pool_metrics = CurrentMetrics::Increment{CurrentMetrics::StoragePoolV3Only};
}
else // Still running Mix Mode
{
max_log_page_id = std::max(v2_log_max_ids[0], global_storage_pool->getLogMaxId(ns_id));
max_data_page_id = std::max(v2_data_max_ids[0], global_storage_pool->getDataMaxId(ns_id));
max_meta_page_id = std::max(v2_meta_max_ids[0], global_storage_pool->getMetaMaxId(ns_id));
storage_pool_metrics = CurrentMetrics::Increment{CurrentMetrics::StoragePoolMixMode};
}
break;
}
Expand Down
2 changes: 2 additions & 0 deletions dbms/src/Storages/DeltaMerge/StoragePool.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,8 @@ class StoragePool : private boost::noncopyable
std::atomic<PageId> max_meta_page_id = 0;

BackgroundProcessingPool::TaskHandle gc_handle = nullptr;

CurrentMetrics::Increment storage_pool_metrics;
};

struct StorageSnapshot : private boost::noncopyable
Expand Down
6 changes: 6 additions & 0 deletions dbms/src/Storages/Transaction/RegionPersister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@

#include <memory>

namespace CurrentMetrics
{
extern const Metric RegionPersisterRunMode;
}

namespace DB
{
namespace ErrorCodes
Expand Down Expand Up @@ -263,6 +268,7 @@ RegionMap RegionPersister::restore(const TiFlashRaftProxyHelper * proxy_helper,
}
}

CurrentMetrics::set(CurrentMetrics::RegionPersisterRunMode, static_cast<UInt8>(run_mode));
LOG_FMT_INFO(log, "RegionPersister running. Current Run Mode is {}", static_cast<UInt8>(run_mode));
}

Expand Down
Loading

0 comments on commit 3434d4f

Please sign in to comment.