Use max_analyze_depth

This commit is contained in:
vdimir 2022-08-18 09:21:07 +00:00 committed by Vladimir C
parent 928adb2b38
commit f38f39ed6f
3 changed files with 7 additions and 4 deletions

View File

@ -347,6 +347,7 @@ static constexpr UInt64 operator""_GiB(unsigned long long value)
\
M(UInt64, max_subquery_depth, 100, "If a query has more than specified number of nested subqueries, throw an exception. This allows you to have a sanity check to protect the users of your cluster from going insane with their queries.", 0) \
M(UInt64, max_pipeline_depth, 1000, "If a query has more than specified stages in the query pipeline, throw an exception. Pipeline has stages for every relational operator. This allows to limit the complexity of the queries.", 0) \
M(UInt64, max_analyze_depth, 10000, "", 0) \
M(UInt64, max_ast_depth, 1000, "Maximum depth of query syntax tree. Checked after parsing.", 0) \
M(UInt64, max_ast_elements, 50000, "Maximum size of query syntax tree in number of nodes. Checked after parsing.", 0) \
M(UInt64, max_expanded_ast_elements, 500000, "Maximum size of query syntax tree in number of nodes after expansion of aliases and the asterisk.", 0) \
@ -672,6 +673,8 @@ static constexpr UInt64 operator""_GiB(unsigned long long value)
MAKE_OBSOLETE(M, UInt64, background_message_broker_schedule_pool_size, 16) \
MAKE_OBSOLETE(M, UInt64, background_distributed_schedule_pool_size, 16) \
MAKE_OBSOLETE(M, DefaultDatabaseEngine, default_database_engine, DefaultDatabaseEngine::Atomic) \
MAKE_OBSOLETE(M, UInt64, max_pipeline_depth, 0) \
/** The section above is for obsolete settings. Do not add anything there. */

View File

@ -501,8 +501,8 @@ InterpreterSelectQuery::InterpreterSelectQuery(
{
std::atomic<size_t> & current_query_analyze_count = context->getQueryContext()->kitchen_sink.analyze_counter;
++current_query_analyze_count;
if (settings.max_pipeline_depth && current_query_analyze_count >= settings.max_pipeline_depth)
throw DB::Exception(ErrorCodes::TOO_DEEP_PIPELINE, "Query analyze overflow. Try to increase `max_pipeline_depth` or simplify the query");
if (settings.max_analyze_depth && current_query_analyze_count >= settings.max_analyze_depth)
throw DB::Exception(ErrorCodes::TOO_DEEP_RECURSION, "Query analyze overflow. Try to increase `max_analyze_depth` or simplify the query");
}
/// Allow push down and other optimizations for VIEW: replace with subquery and rewrite it.

View File

@ -2,7 +2,7 @@
-- https://github.com/ClickHouse/ClickHouse/issues/21557
SET max_pipeline_depth = 1000;
SET max_analyze_depth = 1000;
EXPLAIN SYNTAX
WITH
@ -12,4 +12,4 @@ WITH
FROM x, x AS d1, x AS d2, x AS d3, x AS d4, x AS d5, x AS d6, x AS d7, x AS d8, x AS d9
WHERE x.number = d9.number
)
SELECT xx FROM cross_sales WHERE xx = 2000; -- { serverError TOO_DEEP_PIPELINE }
SELECT xx FROM cross_sales WHERE xx = 2000; -- { serverError TOO_DEEP_RECURSION }