Skip to content

Revert "Significantly optimize JSON-to-JSON type conversion to avoid full serialize+parse" - #133935

Closed
groeneai wants to merge 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/revert-107866
Closed

groeneai wants to merge 1 commit into
ClickHouse:masterfrom
groeneai:groeneai/revert-107866

Conversation

@groeneai

@groeneai groeneai commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Reverts #107866

Related: #107866

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

Description

#107866 introduced a server crash (UBSan unsigned integer overflow: 0 - 1 in convertObjectColumns, on a JSON-to-JSON CAST of a column with shared data). It aborts the server in the amd_asan_ubsan and arm_asan_ubsan stateless jobs on every master commit since the merge (report). The reproducer crashes at the merge commit e903e88 and not at its first parent ace90f6 (amd_asan_ubsan builds, 5/5 vs 0/10 runs) and still crashes on master 022011d. The new code reads offsets[row - 1] at row = 0, which #120906 made fatal. An alternative fix is open in #133910.

Proof

merge-attribution.py prove, amd_asan_ubsan, clickhouse local, GIT_HASH verified per build (the merge commit and its first parent built from source with the sanitizer flags of CI, because the first parent has no CI binary; master is the CI binary):

Build sha Runs UBSan abort Site
merge commit e903e88 5 5 FunctionsConversion.cpp:3649:55
first parent ace90f6 10 0 -
master 022011d 5 5 FunctionsConversion.cpp:3649:55

The reverse CAST gives the same 5/0/5 at FunctionsConversion.cpp:2929:73 (newLeafTypedPathsNeedFormatParse).

On this revert (amd_asan_ubsan build): both reproducers 0 aborts in 10/10 runs each, both return {"a":1,"b":2}. The restored tests 03272_json_to_json_alter, 03272_json_to_json_cast_{1..6} and 05301_json_shared_typed_paths_alter pass (the no-asan one on a debug build of the same commit).

SELECT CAST(materialize('{"a":1,"b":2}')::JSON(max_dynamic_paths = 0, a UInt32), 'JSON(max_dynamic_paths = 0)') FORMAT Null;
SELECT CAST(materialize('{"a":1,"b":2}')::JSON(max_dynamic_paths = 0), 'JSON(max_dynamic_paths = 0, a UInt32)') FORMAT Null;

🤖 Generated with Claude Code


Workflow [PR]
Sync PR [sync-upstream/pr/133935]

…-json-type-conversion"

This reverts commit e903e88, reversing
changes made to ace90f6.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@groeneai

Copy link
Copy Markdown
Collaborator Author
Internal second-model review (click to expand)

Pure revert of #107866: re-applying its diff (ace90f6ea6fb...e903e8848f03) to this head gives the tree of master a7735de exactly. Second-model review: 1 finding, not blocking: the revert also brings back the pre-#107866 JSON input fast path, which stores a numeric string in a dynamic path (with date inference off) or in shared data as String even with input_format_json_try_infer_numbers_from_strings = 1. That code is byte-identical to the 26.11 release; the alternative fix #133910 keeps the #107866 version.

@groeneai

Copy link
Copy Markdown
Collaborator Author

cc @Avogar, could you review this? This reverts #107866, which crashes the server (UBSan unsigned overflow in convertObjectColumns) on a JSON-to-JSON CAST of a column with shared data: the reproducer crashes at e903e88 and not at ace90f6. The fix in #133910 is the alternative.

@clickhouse-gh

clickhouse-gh Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [2915694]

Summary: ✅

@clickhouse-gh clickhouse-gh Bot added pr-not-for-changelog This PR should not be mentioned in the changelog can be tested Allows running workflows for external contributors comp-json-datatype JSON/Dynamic/Object datatype: semi-structured column storage, typed and dynamic paths, sub-object... labels Nov 24, 2026
@groeneai

Copy link
Copy Markdown
Collaborator Author

Closing: fixed by #133910, so this revert is no longer needed.

@groeneai groeneai closed this Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors comp-json-datatype JSON/Dynamic/Object datatype: semi-structured column storage, typed and dynamic paths, sub-object... pr-not-for-changelog This PR should not be mentioned in the changelog

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant