Fix FunctionVariantAdaptor wrapping non-type exceptions as LOGICAL_ERROR#102855
Conversation
ExecutableFunctionVariantAdaptor::executeImpl() has 7 catch blocks around castColumn() calls that catch ALL exceptions and re-throw them as LOGICAL_ERROR. This is wrong: non-type-conversion exceptions like MEMORY_LIMIT_EXCEEDED should propagate as-is, not trigger abortOnFailedAssertion() and crash the server. The fix adds error code filtering to all 7 catch blocks: only type-related exceptions (ILLEGAL_TYPE_OF_ARGUMENT, TYPE_MISMATCH, CANNOT_CONVERT_TYPE, NO_COMMON_TYPE) are wrapped as LOGICAL_ERROR. All other exceptions are re-thrown unchanged. This matches the pattern already used in the FunctionBaseVariantAdaptor constructor. Fixes: ClickHouse#93960
Pre-PR Validation Gate (session: cron:clickhouse-ci-task-worker:20260415-194500)a) Deterministic repro? ✅ b) Root cause explained? ✅ c) Fix matches root cause? ✅ Added error code filtering to all 7 catch blocks: only d) New tests added? ✅ e) Demonstrated in both directions? ✅ Before fix: server crashes. After fix: returns code 241 MEMORY_LIMIT_EXCEEDED, server stays alive. 10/10 test runs pass. f) Fix is general? ✅ All 7 catch blocks fixed, covering every execution path in |
|
cc @Avogar @alexey-milovidov — could you review this? It fixes a server crash where |
|
Workflow [PR], commit [4b7f9ee] Summary: ✅ AI ReviewSummaryThis PR fixes exception classification in ClickHouse Rules
Final Verdict
|
LLVM Coverage Report
Changed lines: 23.81% (10/42) · Uncovered code |
|
|
ExecutableFunctionVariantAdaptor::executeImpl()has 7catch (const Exception & e)blocks aroundcastColumn()calls that catch ALL exceptions and re-throw them asLOGICAL_ERROR. Non-type-conversion exceptions likeMEMORY_LIMIT_EXCEEDEDare incorrectly wrapped, causingabortOnFailedAssertion()to crash the server instead of returning a user-facing error.Root cause: When a function applied to a
Variantcolumn triggers OOM insidecastColumn()(which converts the result to the expected Variant type), the OOM exception is caught and re-thrown as:This LOGICAL_ERROR triggers the assertion handler and kills the server.
Fix: Added error code filtering to all 7 catch blocks. Only type-conversion errors (
ILLEGAL_TYPE_OF_ARGUMENT,TYPE_MISMATCH,CANNOT_CONVERT_TYPE,NO_COMMON_TYPE) are wrapped asLOGICAL_ERROR. All other exceptions propagate as-is. This matches the existing pattern in theFunctionBaseVariantAdaptorconstructor (which already filters these exact codes).Reproduction:
All 3 execution paths in
executeImplare covered:Fixes #93960
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix server crash (LOGICAL_ERROR assertion) when a function on a
Variantcolumn hits a memory limit or other non-type-conversion exception during result casting inFunctionVariantAdaptor. The exception is now propagated correctly instead of being misclassified as an internal error.Documentation entry for user-facing changes