Skip to content

Commit 3c02c1f

Browse files
authored
Merge pull request ClickHouse#80224 from Algunenano/threads_logical
Force backup_threads and restore_threads to be non zero
2 parents 47b21be + b508a1d commit 3c02c1f

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

src/Core/ServerSettings.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ namespace DB
139139
A value of `0` (default) means unlimited.
140140
:::
141141
)", 0) \
142-
DECLARE(UInt64, backup_threads, 16, R"(The maximum number of threads to execute `BACKUP` requests.)", 0) \
142+
DECLARE(NonZeroUInt64, backup_threads, 16, R"(The maximum number of threads to execute `BACKUP` requests.)", 0) \
143143
DECLARE(UInt64, max_backup_bandwidth_for_server, 0, R"(The maximum read speed in bytes per second for all backups on server. Zero means unlimited.)", 0) \
144-
DECLARE(UInt64, restore_threads, 16, R"(The maximum number of threads to execute RESTORE requests.)", 0) \
144+
DECLARE(NonZeroUInt64, restore_threads, 16, R"(The maximum number of threads to execute RESTORE requests.)", 0) \
145145
DECLARE(Bool, shutdown_wait_backups_and_restores, true, R"(If set to true ClickHouse will wait for running backups and restores to finish before shutdown.)", 0) \
146146
DECLARE(Double, cannot_allocate_thread_fault_injection_probability, 0, R"(For testing purposes.)", 0) \
147147
DECLARE(Int32, max_connections, 4096, R"(Max server connections.)", 0) \

src/Core/ServerSettings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ struct ServerSettingsImpl;
2121
M(CLASS_NAME, Double) \
2222
M(CLASS_NAME, GroupArrayActionWhenLimitReached) \
2323
M(CLASS_NAME, Float) \
24+
M(CLASS_NAME, NonZeroUInt64) \
2425
M(CLASS_NAME, Int32) \
2526
M(CLASS_NAME, Seconds) \
2627
M(CLASS_NAME, String) \

src/Interpreters/Context.cpp

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ namespace Setting
197197
extern const SettingsUInt64 allow_experimental_parallel_reading_from_replicas;
198198
extern const SettingsMilliseconds async_insert_poll_timeout_ms;
199199
extern const SettingsBool azure_allow_parallel_part_upload;
200-
extern const SettingsUInt64 backup_threads;
201200
extern const SettingsString cluster_for_parallel_replicas;
202201
extern const SettingsBool enable_filesystem_cache;
203202
extern const SettingsBool enable_filesystem_cache_log;
@@ -245,7 +244,6 @@ namespace Setting
245244
extern const SettingsUInt64 page_cache_block_size;
246245
extern const SettingsUInt64 page_cache_lookahead_blocks;
247246
extern const SettingsInt64 read_priority;
248-
extern const SettingsUInt64 restore_threads;
249247
extern const SettingsString remote_filesystem_read_method;
250248
extern const SettingsBool remote_filesystem_read_prefetch;
251249
extern const SettingsUInt64 remote_fs_read_max_backoff_ms;
@@ -3256,9 +3254,9 @@ BackupsWorker & Context::getBackupsWorker() const
32563254
{
32573255
callOnce(shared->backups_worker_initialized, [&] {
32583256
const auto & config = getConfigRef();
3259-
const auto & settings_ref = getSettingsRef();
3260-
UInt64 backup_threads = config.getUInt64("backup_threads", settings_ref[Setting::backup_threads]);
3261-
UInt64 restore_threads = config.getUInt64("restore_threads", settings_ref[Setting::restore_threads]);
3257+
Poco::UInt64 max_threads_max_value = 256 * getNumberOfCPUCoresToUse(); /// Limit to something unreasonable
3258+
size_t backup_threads = std::min(max_threads_max_value, std::max(Poco::UInt64{1}, config.getUInt64("backup_threads", 16)));
3259+
size_t restore_threads = std::min(max_threads_max_value, std::max(Poco::UInt64{1}, config.getUInt64("restore_threads", 16)));
32623260

32633261
shared->backups_worker.emplace(getGlobalContext(), backup_threads, restore_threads);
32643262
});

0 commit comments

Comments
 (0)