mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-02 12:32:04 +00:00
Don't allow 0 for max_block_size
This commit is contained in:
parent
18858ca26f
commit
13fc7c7cf8
@ -92,7 +92,7 @@ void applySettingsQuirks(Settings & settings, LoggerPtr log)
|
|||||||
|
|
||||||
void doSettingsSanityCheckClamp(Settings & current_settings, LoggerPtr log)
|
void doSettingsSanityCheckClamp(Settings & current_settings, LoggerPtr log)
|
||||||
{
|
{
|
||||||
auto getCurrentValue = [¤t_settings](const std::string_view name) -> Field
|
auto get_current_value = [¤t_settings](const std::string_view name) -> Field
|
||||||
{
|
{
|
||||||
Field current_value;
|
Field current_value;
|
||||||
bool has_current_value = current_settings.tryGet(name, current_value);
|
bool has_current_value = current_settings.tryGet(name, current_value);
|
||||||
@ -100,7 +100,7 @@ void doSettingsSanityCheckClamp(Settings & current_settings, LoggerPtr log)
|
|||||||
return current_value;
|
return current_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
UInt64 max_threads = getCurrentValue("max_threads").get<UInt64>();
|
UInt64 max_threads = get_current_value("max_threads").get<UInt64>();
|
||||||
UInt64 max_threads_max_value = 256 * getNumberOfPhysicalCPUCores();
|
UInt64 max_threads_max_value = 256 * getNumberOfPhysicalCPUCores();
|
||||||
if (max_threads > max_threads_max_value)
|
if (max_threads > max_threads_max_value)
|
||||||
{
|
{
|
||||||
@ -109,7 +109,7 @@ void doSettingsSanityCheckClamp(Settings & current_settings, LoggerPtr log)
|
|||||||
current_settings.set("max_threads", max_threads_max_value);
|
current_settings.set("max_threads", max_threads_max_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr UInt64 max_sane_block_rows_size = 4294967296; // 2^32
|
static constexpr UInt64 max_sane_block_rows_size = 4294967296; // 2^32
|
||||||
std::unordered_set<String> block_rows_settings{
|
std::unordered_set<String> block_rows_settings{
|
||||||
"max_block_size",
|
"max_block_size",
|
||||||
"max_insert_block_size",
|
"max_insert_block_size",
|
||||||
@ -120,7 +120,7 @@ void doSettingsSanityCheckClamp(Settings & current_settings, LoggerPtr log)
|
|||||||
"input_format_parquet_max_block_size"};
|
"input_format_parquet_max_block_size"};
|
||||||
for (auto const & setting : block_rows_settings)
|
for (auto const & setting : block_rows_settings)
|
||||||
{
|
{
|
||||||
auto block_size = getCurrentValue(setting).get<UInt64>();
|
auto block_size = get_current_value(setting).get<UInt64>();
|
||||||
if (block_size > max_sane_block_rows_size)
|
if (block_size > max_sane_block_rows_size)
|
||||||
{
|
{
|
||||||
if (log)
|
if (log)
|
||||||
@ -128,5 +128,13 @@ void doSettingsSanityCheckClamp(Settings & current_settings, LoggerPtr log)
|
|||||||
current_settings.set(setting, max_sane_block_rows_size);
|
current_settings.set(setting, max_sane_block_rows_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (auto max_block_size = get_current_value("max_block_size").get<UInt64>(); max_block_size == 0)
|
||||||
|
{
|
||||||
|
if (log)
|
||||||
|
LOG_WARNING(log, "Sanity check: 'max_block_size' cannot be 0. Set to default value {}", DEFAULT_BLOCK_SIZE);
|
||||||
|
current_settings.set("max_block_size", DEFAULT_BLOCK_SIZE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -176,9 +176,8 @@ protected:
|
|||||||
{
|
{
|
||||||
std::lock_guard lock(ranges_state->mutex);
|
std::lock_guard lock(ranges_state->mutex);
|
||||||
|
|
||||||
UInt64 need = base_block_size_;
|
|
||||||
bool without_block_size_limit = need == 0;
|
|
||||||
|
|
||||||
|
UInt64 need = base_block_size_;
|
||||||
UInt64 size = 0; /// how many item found.
|
UInt64 size = 0; /// how many item found.
|
||||||
|
|
||||||
/// find start
|
/// find start
|
||||||
@ -186,21 +185,14 @@ protected:
|
|||||||
end = start;
|
end = start;
|
||||||
|
|
||||||
/// find end
|
/// find end
|
||||||
while (without_block_size_limit || need != 0)
|
while (need != 0)
|
||||||
{
|
{
|
||||||
UInt128 can_provide = end.offset_in_ranges == ranges.size() ? static_cast<UInt128>(0)
|
UInt128 can_provide = end.offset_in_ranges == ranges.size() ? static_cast<UInt128>(0)
|
||||||
: ranges[end.offset_in_ranges].size - end.offset_in_range;
|
: ranges[end.offset_in_ranges].size - end.offset_in_range;
|
||||||
|
|
||||||
if (can_provide == 0)
|
if (can_provide == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (without_block_size_limit)
|
if (can_provide > need)
|
||||||
{
|
|
||||||
end.offset_in_ranges++;
|
|
||||||
end.offset_in_range = 0;
|
|
||||||
size += static_cast<UInt64>(can_provide);
|
|
||||||
}
|
|
||||||
else if (can_provide > need)
|
|
||||||
{
|
{
|
||||||
end.offset_in_range += need;
|
end.offset_in_range += need;
|
||||||
size += need;
|
size += need;
|
||||||
@ -535,7 +527,7 @@ Pipe ReadFromSystemNumbersStep::makePipe()
|
|||||||
|
|
||||||
checkLimits(size_t(total_size));
|
checkLimits(size_t(total_size));
|
||||||
|
|
||||||
if (max_block_size != 0 && total_size / max_block_size < num_streams)
|
if (total_size / max_block_size < num_streams)
|
||||||
num_streams = static_cast<size_t>(total_size / max_block_size);
|
num_streams = static_cast<size_t>(total_size / max_block_size);
|
||||||
|
|
||||||
if (num_streams == 0)
|
if (num_streams == 0)
|
||||||
|
@ -1,2 +1 @@
|
|||||||
1320
|
OK
|
||||||
1320
|
|
||||||
|
7
tests/queries/0_stateless/03149_numbers_max_block_size_zero.sh
Executable file
7
tests/queries/0_stateless/03149_numbers_max_block_size_zero.sh
Executable file
@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
CUR_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||||
|
# shellcheck source=../shell_config.sh
|
||||||
|
. "$CUR_DIR"/../shell_config.sh
|
||||||
|
|
||||||
|
$CLICKHOUSE_CLIENT -q "SELECT count(*) FROM numbers(10) AS a, numbers(11) AS b, numbers(12) AS c SETTINGS max_block_size = 0" 2>&1 | grep -q "Sanity check: 'max_block_size' cannot be 0. Set to default value" && echo "OK" || echo "FAIL"
|
@ -1,2 +0,0 @@
|
|||||||
SELECT count(*) FROM numbers(10) AS a, numbers(11) AS b, numbers(12) AS c SETTINGS max_block_size = 0;
|
|
||||||
SELECT count(*) FROM numbers(10) AS a, numbers(11) AS b, numbers(12) AS c SETTINGS max_block_size = 1;
|
|
Loading…
Reference in New Issue
Block a user