From 8bd8cefb0018f975053372c73b1da6e729a169aa Mon Sep 17 00:00:00 2001 From: HeYuchen <377710264@qq.com> Date: Mon, 23 Mar 2020 18:13:05 +0800 Subject: [PATCH] feat: add a new app_env to limit scan time (#421) --- include/dsn/dist/replication/replica_envs.h | 1 + src/dist/replication/common/replication_common.cpp | 2 ++ .../replication/meta_server/app_env_validator.cpp | 12 ++++++++++++ 3 files changed, 15 insertions(+) diff --git a/include/dsn/dist/replication/replica_envs.h b/include/dsn/dist/replication/replica_envs.h index 464427ec45..5be5c26740 100644 --- a/include/dsn/dist/replication/replica_envs.h +++ b/include/dsn/dist/replication/replica_envs.h @@ -44,6 +44,7 @@ class replica_envs static const std::string ROCKSDB_USAGE_SCENARIO; static const std::string ROCKSDB_CHECKPOINT_RESERVE_MIN_COUNT; static const std::string ROCKSDB_CHECKPOINT_RESERVE_TIME_SECONDS; + static const std::string ROCKSDB_ITERATION_THRESHOLD_TIME_MS; static const std::string MANUAL_COMPACT_DISABLED; static const std::string MANUAL_COMPACT_MAX_CONCURRENT_RUNNING_COUNT; static const std::string MANUAL_COMPACT_ONCE_TRIGGER_TIME; diff --git a/src/dist/replication/common/replication_common.cpp b/src/dist/replication/common/replication_common.cpp index d681ca6fdc..a7d64eec2a 100644 --- a/src/dist/replication/common/replication_common.cpp +++ b/src/dist/replication/common/replication_common.cpp @@ -618,6 +618,8 @@ const std::string replica_envs::ROCKSDB_CHECKPOINT_RESERVE_MIN_COUNT("rocksdb.checkpoint.reserve_min_count"); const std::string replica_envs::ROCKSDB_CHECKPOINT_RESERVE_TIME_SECONDS( "rocksdb.checkpoint.reserve_time_seconds"); +const std::string replica_envs::ROCKSDB_ITERATION_THRESHOLD_TIME_MS( + "replica.rocksdb_iteration_threshold_time_ms"); const std::string replica_envs::BUSINESS_INFO("business.info"); namespace cold_backup { diff --git a/src/dist/replication/meta_server/app_env_validator.cpp b/src/dist/replication/meta_server/app_env_validator.cpp index 25e7174cfb..7bd4a8a003 100644 --- a/src/dist/replication/meta_server/app_env_validator.cpp +++ b/src/dist/replication/meta_server/app_env_validator.cpp @@ -53,6 +53,16 @@ bool check_slow_query(const std::string &env_value, std::string &hint_message) return true; } +bool check_rocksdb_iteration(const std::string &env_value, std::string &hint_message) +{ + uint64_t threshold = 0; + if (!dsn::buf2uint64(env_value, threshold) || threshold < 0) { + hint_message = "Rocksdb iteration threshold must be greater than zero"; + return false; + } + return true; +} + bool check_write_throttling(const std::string &env_value, std::string &hint_message) { std::vector sargs; @@ -141,6 +151,8 @@ void app_env_validator::register_all_validators() std::bind(&check_write_throttling, std::placeholders::_1, std::placeholders::_2)}, {replica_envs::WRITE_SIZE_THROTTLING, std::bind(&check_write_throttling, std::placeholders::_1, std::placeholders::_2)}, + {replica_envs::ROCKSDB_ITERATION_THRESHOLD_TIME_MS, + std::bind(&check_rocksdb_iteration, std::placeholders::_1, std::placeholders::_2)}, // TODO(zhaoliwei): not implemented {replica_envs::BUSINESS_INFO, nullptr}, {replica_envs::DENY_CLIENT_WRITE, nullptr},