Skip to content

Commit db91610

Browse files
Merge pull request ClickHouse#90774 from ClickHouse/backport/25.8/90438
Backport ClickHouse#90438 to 25.8: Update warning messages when approaching guardrails limits: show current and throw values
2 parents b0f2dd7 + 7b77eaf commit db91610

File tree

5 files changed

+328
-107
lines changed

5 files changed

+328
-107
lines changed

src/Interpreters/Context.cpp

Lines changed: 64 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,11 @@ namespace ServerSetting
360360
extern const ServerSettingsUInt64 iceberg_catalog_threadpool_pool_size;
361361
extern const ServerSettingsUInt64 iceberg_catalog_threadpool_queue_size;
362362
extern const ServerSettingsBool dictionaries_lazy_load;
363+
extern const ServerSettingsInt32 os_threads_nice_value_zookeeper_client_send_receive;
364+
extern const ServerSettingsUInt64 max_table_num_to_throw;
365+
extern const ServerSettingsUInt64 max_view_num_to_throw;
366+
extern const ServerSettingsUInt64 max_dictionary_num_to_throw;
367+
extern const ServerSettingsUInt64 max_database_num_to_throw;
363368
}
364369

365370
namespace ErrorCodes
@@ -1324,16 +1329,65 @@ std::unordered_map<Context::WarningType, PreformattedMessage> Context::getWarnin
13241329
{
13251330
SharedLockGuard lock(shared->mutex);
13261331
common_warnings = shared->warnings;
1327-
if (CurrentMetrics::get(CurrentMetrics::AttachedTable) > static_cast<Int64>(shared->max_table_num_to_warn))
1328-
common_warnings[Context::WarningType::MAX_ATTACHED_TABLES] = PreformattedMessage::create("The number of attached tables is more than {}.", shared->max_table_num_to_warn.load());
1329-
if (CurrentMetrics::get(CurrentMetrics::AttachedView) > static_cast<Int64>(shared->max_view_num_to_warn))
1330-
common_warnings[Context::WarningType::MAX_ATTACHED_VIEWS] = PreformattedMessage::create("The number of attached views is more than {}.", shared->max_view_num_to_warn.load());
1331-
if (CurrentMetrics::get(CurrentMetrics::AttachedDictionary) > static_cast<Int64>(shared->max_dictionary_num_to_warn))
1332-
common_warnings[Context::WarningType::MAX_ATTACHED_DICTIONARIES] = PreformattedMessage::create("The number of attached dictionaries is more than {}.", shared->max_dictionary_num_to_warn.load());
1333-
if (CurrentMetrics::get(CurrentMetrics::AttachedDatabase) > static_cast<Int64>(shared->max_database_num_to_warn))
1334-
common_warnings[Context::WarningType::MAX_ATTACHED_DATABASES] = PreformattedMessage::create("The number of attached databases is more than {}.", shared->max_database_num_to_warn.load());
1335-
if (CurrentMetrics::get(CurrentMetrics::PartsActive) > static_cast<Int64>(shared->max_part_num_to_warn))
1336-
common_warnings[Context::WarningType::MAX_ACTIVE_PARTS] = PreformattedMessage::create("The number of active parts is more than {}.", shared->max_part_num_to_warn.load());
1332+
1333+
auto attached_tables = CurrentMetrics::get(CurrentMetrics::AttachedTable);
1334+
auto attached_views = CurrentMetrics::get(CurrentMetrics::AttachedView);
1335+
auto attached_dictionaries = CurrentMetrics::get(CurrentMetrics::AttachedDictionary);
1336+
auto attached_databases = CurrentMetrics::get(CurrentMetrics::AttachedDatabase);
1337+
auto active_parts = CurrentMetrics::get(CurrentMetrics::PartsActive);
1338+
1339+
if (attached_tables > static_cast<Int64>(shared->max_table_num_to_warn))
1340+
{
1341+
if (auto limit = shared->server_settings[ServerSetting::max_table_num_to_throw]; limit > shared->max_table_num_to_warn.load())
1342+
common_warnings[Context::WarningType::MAX_ATTACHED_TABLES] = PreformattedMessage::create(
1343+
"The number of attached tables ({}) exceeds the warning limit of {}. You will not be able to create new tables once the limit of {} is reached.",
1344+
attached_tables, shared->max_table_num_to_warn.load(), limit.value);
1345+
else
1346+
common_warnings[Context::WarningType::MAX_ATTACHED_TABLES] = PreformattedMessage::create(
1347+
"The number of attached tables ({}) exceeds the warning limit of {}.",
1348+
attached_tables, shared->max_table_num_to_warn.load());
1349+
}
1350+
1351+
if (attached_views > static_cast<Int64>(shared->max_view_num_to_warn))
1352+
{
1353+
if (auto limit = shared->server_settings[ServerSetting::max_view_num_to_throw]; limit > shared->max_view_num_to_warn.load())
1354+
common_warnings[Context::WarningType::MAX_ATTACHED_VIEWS] = PreformattedMessage::create(
1355+
"The number of attached views ({}) exceeds the warning limit of {}. You will not be able to create new views once the limit of {} is reached.",
1356+
attached_views, shared->max_view_num_to_warn.load(), limit.value);
1357+
else
1358+
common_warnings[Context::WarningType::MAX_ATTACHED_VIEWS] = PreformattedMessage::create(
1359+
"The number of attached views ({}) exceeds the warning limit of {}.",
1360+
attached_views, shared->max_view_num_to_warn.load());
1361+
}
1362+
1363+
if (attached_dictionaries > static_cast<Int64>(shared->max_dictionary_num_to_warn))
1364+
{
1365+
if (auto limit = shared->server_settings[ServerSetting::max_dictionary_num_to_throw]; limit > shared->max_dictionary_num_to_warn.load())
1366+
common_warnings[Context::WarningType::MAX_ATTACHED_DICTIONARIES] = PreformattedMessage::create(
1367+
"The number of attached dictionaries ({}) exceeds the warning limit of {}. You will not be able to create new dictionaries once the limit of {} is reached.",
1368+
attached_dictionaries, shared->max_dictionary_num_to_warn.load(), limit.value);
1369+
else
1370+
common_warnings[Context::WarningType::MAX_ATTACHED_DICTIONARIES] = PreformattedMessage::create(
1371+
"The number of attached dictionaries ({}) exceeds the warning limit of {}.",
1372+
attached_dictionaries, shared->max_dictionary_num_to_warn.load());
1373+
}
1374+
1375+
if (attached_databases > static_cast<Int64>(shared->max_database_num_to_warn))
1376+
{
1377+
if (auto limit = shared->server_settings[ServerSetting::max_database_num_to_throw]; limit > shared->max_database_num_to_warn.load())
1378+
common_warnings[Context::WarningType::MAX_ATTACHED_DATABASES] = PreformattedMessage::create(
1379+
"The number of attached databases ({}) exceeds the warning limit of {}. You will not be able to create new databases once the limit of {} is reached.",
1380+
attached_databases, shared->max_database_num_to_warn.load(), limit.value);
1381+
else
1382+
common_warnings[Context::WarningType::MAX_ATTACHED_DATABASES] = PreformattedMessage::create(
1383+
"The number of attached databases ({}) exceeds the warning limit of {}.",
1384+
attached_databases, shared->max_database_num_to_warn.load());
1385+
}
1386+
1387+
if (active_parts > static_cast<Int64>(shared->max_part_num_to_warn))
1388+
common_warnings[Context::WarningType::MAX_ACTIVE_PARTS] = PreformattedMessage::create(
1389+
"The number of active parts ({}) exceeds the warning limit of {}.",
1390+
active_parts, shared->max_part_num_to_warn.load());
13371391
}
13381392
/// Make setting's name ordered
13391393
auto obsolete_settings = settings->getChangedAndObsoleteNames();

tests/integration/test_table_db_num_limit/config/config.xml

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,31 @@
11
<clickhouse>
22
<remote_servers>
3-
<cluster>
4-
<shard>
5-
<replica>
6-
<host>node1</host>
7-
<port>9000</port>
8-
</replica>
9-
<replica>
10-
<host>node2</host>
11-
<port>9000</port>
12-
</replica>
13-
</shard>
14-
</cluster>
15-
</remote_servers>
3+
<cluster>
4+
<shard>
5+
<replica>
6+
<host>node1</host>
7+
<port>9000</port>
8+
</replica>
9+
<replica>
10+
<host>node2</host>
11+
<port>9000</port>
12+
</replica>
13+
</shard>
14+
</cluster>
15+
</remote_servers>
1616

17-
<max_dictionary_num_to_throw>10</max_dictionary_num_to_throw>
17+
<!-- Limits set to verify Warning/Throw logic -->
18+
<!-- Warning limit is 5, Throw limit is 10 for all metrics to allow consistent testing -->
19+
20+
<max_table_num_to_warn>5</max_table_num_to_warn>
1821
<max_table_num_to_throw>10</max_table_num_to_throw>
22+
23+
<max_view_num_to_warn>5</max_view_num_to_warn>
24+
<max_view_num_to_throw>10</max_view_num_to_throw>
25+
26+
<max_dictionary_num_to_warn>5</max_dictionary_num_to_warn>
27+
<max_dictionary_num_to_throw>10</max_dictionary_num_to_throw>
28+
29+
<max_database_num_to_warn>5</max_database_num_to_warn>
1930
<max_database_num_to_throw>10</max_database_num_to_throw>
2031
</clickhouse>
21-

0 commit comments

Comments
 (0)