Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add metrics for storage pool run mode #4881

Merged
merged 7 commits into from
May 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1652,7 +1653,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.");
}

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 @@ -303,6 +313,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 @@ -311,6 +322,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 @@ -368,12 +380,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 @@ -235,6 +235,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 @@ -320,6 +325,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