Add sanity check for poll_max_batch_size FileLog setting to avoid big untracked allocations

This commit is contained in:
avogar 2024-03-14 20:36:18 +00:00
parent a3373ab580
commit e08eaebc99
3 changed files with 8 additions and 0 deletions

View File

@ -11,6 +11,7 @@ namespace DB
namespace ErrorCodes namespace ErrorCodes
{ {
extern const int UNKNOWN_SETTING; extern const int UNKNOWN_SETTING;
extern const int INVALID_SETTING_VALUE;
} }
IMPLEMENT_SETTINGS_TRAITS(FileLogSettingsTraits, LIST_OF_FILELOG_SETTINGS) IMPLEMENT_SETTINGS_TRAITS(FileLogSettingsTraits, LIST_OF_FILELOG_SETTINGS)
@ -36,6 +37,11 @@ void FileLogSettings::loadFromQuery(ASTStorage & storage_def)
settings_ast->is_standalone = false; settings_ast->is_standalone = false;
storage_def.set(storage_def.settings, settings_ast); storage_def.set(storage_def.settings, settings_ast);
} }
/// Check that batch size is not too high (the same as we check setting max_block_size).
constexpr UInt64 max_sane_block_rows_size = 4294967296; // 2^32
if (poll_max_batch_size > max_sane_block_rows_size)
throw Exception(ErrorCodes::INVALID_SETTING_VALUE, "Sanity check: 'poll_max_batch_size' value is too high ({})", poll_max_batch_size);
} }
} }

View File

@ -0,0 +1,2 @@
create table test (number UInt64) engine=FileLog('./user_files/data.jsonl', 'JSONEachRow') settings poll_max_batch_size=18446744073709; -- {serverError INVALID_SETTING_VALUE}