Repository navigation
Cap recursion-controlling parser/AST settings in fuzzer and stress test - #108863
Algunenano merged 7 commits into
Conversation
The query fuzzer and stress test could run queries that build pathologically
deep/large expressions, taking minutes to parse and format and tripping the
hung check, e.g.:
SELECT formatQuery($$SELECT [[[[ ...20000... ]]]]$$)
with `max_parser_depth=100000000`. The stress test ignores `no-*` build tags
(`tests/clickhouse-test`) and runs the fuzzer over every query, so a single
test setting these high is enough to hang the server under sanitizers.
Move the recursion constraints out of `query-fuzzer-tweaks-users.xml` into a
shared `limit-recursion-settings.xml` and install it in both the AST fuzzer and
the stress runner. It caps `max_ast_depth`, `max_parser_depth`,
`max_parser_backtracks`, `max_ast_elements` and `max_expanded_ast_elements` at
their defaults via `<max>` (lowering is still allowed), so neither the fuzzer
nor a test can raise them to values that build huge queries.
Seen in: https://s3.amazonaws.com/clickhouse-test-reports/PRs/108593/633f156999f8febe513b07e4334382a758e0a1ec/stress_test_amd_tsan/hung_check.log
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
Workflow [PR], commit [0139045] Summary: ✅ AI ReviewSummaryThis PR moves the recursion-setting caps into a shared Findings❌ Blockers
Final VerdictStatus: |
`0` means "unlimited" for all of these settings and disables the guard: `parseQuery` only calls `checkDepth` when `max_parser_depth` is non-zero, `IParser` only enforces the backtrack budget when `max_parser_backtracks` is non-zero, and `executeQuery` skips the `max_ast_depth` / `max_ast_elements` checks when the setting is `0`. A `<max>` constraint alone therefore still let the fuzzer emit `SET max_parser_depth = 0` (etc.) to remove the safeguard. Add `<min>1</min>` alongside each `<max>` so the valid range is [1, default]. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…ings' into cap-fuzzer-stress-recursion-settings
… below the min constraint
| # tags and runs the query fuzzer over every query, so deeply nested expressions (e.g. test | ||
| # 04412's formatQuery of a 20000-deep array literal) would otherwise build huge queries that | ||
| # hang the server under sanitizers and trip the hung check. | ||
| cp -av --dereference /repo/ci/jobs/scripts/fuzzer/limit-recursion-settings.xml /etc/clickhouse-server/users.d/ |
There was a problem hiding this comment.
clickhouse-test --stress-tests still runs the shell tests, and those wrappers append their own client flags after CLICKHOUSE_CLIENT_OPT (tests/queries/shell_config.sh:36-38). That means the new server-side profile here does not actually neutralize the stress case called out in the comment: 04411_deep_nested_field_to_type.sh:22 and 04412_deep_nested_literal_format.sh:19 both invoke $CLICKHOUSE_CLIENT --max_parser_depth=100000000, so the client-side parser still sees the uncapped depth and can spend minutes building the same 20k/30k-deep AST before the query ever reaches the constrained server session. In other words, copying limit-recursion-settings.xml into users.d fixes the server half, but the stress job can still hang in the shell-test client path. This needs a client-side enforcement that shell tests cannot override, or those deep-recursion shell tests need to be excluded from --stress-tests.
…s-recursion-settings Cap recursion-controlling parser/AST settings in fuzzer and stress test
The query fuzzer and the stress test could run queries that build pathologically deep or large expressions, taking minutes to parse and format and tripping the hung check. For example:
run with
max_parser_depth=100000000. The stress test ignoresno-*build tags (seetests/clickhouse-test) and runs the fuzzer over every query, so a single test raising these settings is enough to hang the server under sanitizers.The recursion constraints are moved out of
query-fuzzer-tweaks-users.xmlinto a sharedlimit-recursion-settings.xml, installed by both the AST fuzzer and the stress runner. It capsmax_ast_depth,max_parser_depth,max_parser_backtracks,max_ast_elementsandmax_expanded_ast_elementsat their defaults via<max>(lowering is still allowed), so neither the fuzzer nor a test can raise them to values that build huge queries.Seen in: https://s3.amazonaws.com/clickhouse-test-reports/PRs/108593/633f156999f8febe513b07e4334382a758e0a1ec/stress_test_amd_tsan/hung_check.log
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Version info
26.7.1.553(included in26.7and later)