Skip to content

Fix not applying max_dynamic_subcolumns_in_json_type_parsing for inserts in some cases - #115329

Merged
Avogar merged 5 commits into
masterfrom
async-json-dynamic
Aug 25, 2026
Merged

Avogar merged 5 commits into
masterfrom
async-json-dynamic

Conversation

@Felixoid

@Felixoid Felixoid commented Aug 18, 2026 •

Copy link
Copy Markdown
Member

closes #115319

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fixes asynchronous inserts into JSON columns ignoring the max_dynamic_subcolumns_in_json_type_parsing setting. Previously, an asynchronous insert (async_insert = 1) could store more dynamic paths than the setting allows, giving a different column layout than a synchronous insert with the same settings. The cap is now preserved when asynchronous inserts aggregate parsed data.


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

Version info

  • Backported to: 26.8.1.2008, 26.7.6.32, 26.6.5.78, 26.3.33.16

@clickhouse-gh

clickhouse-gh Bot commented Aug 18, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [8848c4b]

Summary: ❌

job_name test_name status info comment
Bugfix validation (unit tests) ERROR
Bugfix validation (unit tests) ERROR

AI Review

Summary

This PR adds a per-column max_dynamic_paths_upper_bound and propagates it through insertFrom / insertRangeFrom, which fixes the main async-insert and squashing paths for max_dynamic_subcolumns_in_json_type_parsing, including the default-row and nested-object cases raised in the earlier review threads. The remaining gap is the already-discussed Native / preprocessed path: once a JSON value has been deserialized from Dynamic / Object binary, the new upper bound is gone, so a preprocessed async batch can still widen the layout beyond the parsing cap.

Missing context / blind spots
  • ⚠️ As of 2026-08-24, the PR only exposes the Build profile diff report; I could not validate the normal stateless/integration test matrix from CI.
Findings

⚠️ Majors

Final Verdict

Needs follow-up before I would consider the fix complete: the main text-parsing path is repaired, but the Native / preprocessed async path still breaks the same user-visible invariant.

LLVM Coverage Report

Metric Baseline Current Δ
Lines 87.00% 87.10% +0.10%
Functions 91.90% 91.90% +0.00%
Branches 79.20% 79.30% +0.10%

Changed lines: Changed C/C++ lines covered: 139/150 (92.67%) · Uncovered code

Full report · Diff report

@clickhouse-gh clickhouse-gh Bot added the pr-bugfix Pull request with bugfix, not backported by default label Aug 18, 2026
@Avogar Avogar self-assigned this Aug 18, 2026
@Avogar

Avogar commented Aug 19, 2026

Copy link
Copy Markdown
Member

Approve was accidential, sorry)
I will push new commits here today

`max_dynamic_subcolumns_in_json_type_parsing` is applied to the parsed
`ColumnObject` instance and not to the type, so it was lost whenever parsed
data was aggregated into columns built from the header.

`ColumnObject` now keeps a separate `max_dynamic_paths_upper_bound` that
`prepareForSquashing` restores `max_dynamic_paths` to, and the new
`IColumn::takeDynamicStructureLimitsFrom` carries that bound from the parsed
data over to the columns aggregating it. `global_max_dynamic_paths` is left
alone on purpose: it takes part in `getName`/`structureEquals`, so narrowing it
would make a column mismatch the header built from its own type.

Fixes two cases:
- an asynchronous insert stored more dynamic paths than the setting allows;
- a synchronous insert whose data was split into several blocks kept the limit
  only when the first block happened to overflow into shared data, because
  `prepareForSquashing` raised the limit back whenever shared data was empty.

Closes: #115319

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
`max_dynamic_subcolumns_in_json_type_parsing` was applied only to the column a
JSON value is parsed into, so an object nested inside a dynamic path kept the
limit of its inferred type instead. Apply it in `ObjectJSONNode`, the single
place every object goes through during parsing, so it holds at any nesting
depth.

Replace `takeExactDynamicStructureFrom` and `takeDynamicStructureLimitsFrom`
with one implementation behind two wrappers: both copy the dynamic structure and
its limits, and only the exact one fixes the structure so later inserts cannot
extend it. Copying the structure is what makes a nested limit travel, because
`ColumnDynamic` clones the source's variant column and `cloneEmpty` carries the
limits of a nested `ColumnObject` with it. Aggregation of parsed data now uses
the non-exact variant, which also fixes an asynchronous insert widening the
limit of a nested object while a synchronous one kept it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@clickhouse-gh

clickhouse-gh Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Build profile diff (arm_release)

Comparing 8848c4bdf with master 9cda9df9c (stripped binary size, per-symbol sizes and ThinLTO time; compile times per translation unit against the most recent warmup build that recompiled it).

✅ No significant changes.

Binary sizes
Binary Master PR Δ
programs/clickhouse-stripped 709.23 MiB 706.19 MiB -3.04 MiB (-0.43%)

Only the stripped binary is compared: the official master build keeps debug symbols while PR builds strip them, so the other binaries differ by construction.

Compile time of recompiled translation units

101 translation units recompiled, 876 s compile time in total, 101 of them have a recent master baseline.

Job report

Avogar and others added 2 commits August 19, 2026 20:27
A limit that `max_dynamic_subcolumns_in_json_type_parsing` puts on a parsed
`ColumnObject` instance now travels with the data: `insertFrom` and
`insertRangeFrom` lower the destination's upper bound to the source's. Since
insertions recurse, the limit also reaches a JSON column nested inside a
`Dynamic` without any per-type plumbing, which is how it survives the
aggregation of an asynchronous insert.

This replaces taking the structure explicitly at the aggregation sites, so
`takeExactDynamicStructureFrom`, the columns implementing it,
`StreamingFormatExecutor` and `AsynchronousInsertQueue` all go back to their
previous form.

Also stop the limit from being discarded by a row that reaches the column
before the first parsed object, such as a row where the field is absent or a
default inserted into a typed path: lowering the limit does not need an empty
column, only that the paths already added fit under it.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@Avogar
Avogar added this pull request to the merge queue Aug 25, 2026
@Avogar Avogar added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Aug 25, 2026
@Avogar Avogar changed the title Reshape async-insert columns from first parsed chunk/block Fix not applying max_dynamic_subcolumns_in_json_type_parsing for inserts in some cases Aug 25, 2026
Merged via the queue into master with commit cb1988d Aug 25, 2026
178 of 180 checks passed
@Avogar
Avogar deleted the async-json-dynamic branch August 25, 2026 20:48
@robot-ch-test-poll2 robot-ch-test-poll2 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Aug 25, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-synced-to-cloud The PR is synced to the cloud repo label Aug 25, 2026
clickhouse-gh Bot added a commit that referenced this pull request Aug 26, 2026
Backport #115329 to 26.8: Fix not applying max_dynamic_subcolumns_in_json_type_parsing for inserts in some cases
Felixoid added a commit that referenced this pull request Aug 26, 2026
Backport #115329 to 26.5: Fix not applying max_dynamic_subcolumns_in_json_type_parsing for inserts in some cases
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Aug 28, 2026
…olumns_in_json_type_parsing for inserts in some cases
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Aug 28, 2026
…olumns_in_json_type_parsing for inserts in some cases
clickhouse-gh Bot added a commit that referenced this pull request Aug 29, 2026
Backport #115329 to 26.7: Fix not applying max_dynamic_subcolumns_in_json_type_parsing for inserts in some cases
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Sep 4, 2026
…olumns_in_json_type_parsing for inserts in some cases
@robot-clickhouse robot-clickhouse added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Sep 4, 2026
@robot-ch-test-poll2 robot-ch-test-poll2 removed the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Sep 6, 2026
robot-ch-test-poll4 added a commit that referenced this pull request Sep 6, 2026
Cherry pick #115329 to 26.3: Fix not applying max_dynamic_subcolumns_in_json_type_parsing for inserts in some cases
robot-clickhouse added a commit that referenced this pull request Sep 6, 2026
…json_type_parsing for inserts in some cases
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Sep 6, 2026
Avogar added a commit that referenced this pull request Sep 8, 2026
Backport #115329 to 26.6: Fix not applying max_dynamic_subcolumns_in_json_type_parsing for inserts in some cases
Avogar added a commit that referenced this pull request Sep 8, 2026
Backport #115329 to 26.3: Fix not applying max_dynamic_subcolumns_in_json_type_parsing for inserts in some cases
kewin-robetti pushed a commit to viasoftkorp/ClickHouse that referenced this pull request Sep 11, 2026
…olumns_in_json_type_parsing for inserts in some cases
bytehalo-infra added a commit to sentioxyz/ClickHouse that referenced this pull request Sep 25, 2026
STOR: async inserts into JSON ignore max_dynamic_subcolumns_in_json_type_parsing -> wrong layout.
Effect in the production build a394e92: wrong/failing (the upstream test fails on it and passes on official 26.8.8.8; evidence/fix_ci_20260925/upstream_repro/residual/115329.PROD263.txt).
Upstream patch unchanged, with its test(s): 05019_async_insert_json_max_dynamic_subcolumns_control_on_parsing, 05020_json_max_dynamic_subcolumns_in_parsing_squashing, 05021_json_max_dynamic_subcolumns_in_parsing_nested_objects, 05022_json_max_dynamic_subcolumns_in_parsing_after_default_rows.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-bugfix Pull request with bugfix, not backported by default pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keep the JSON dynamic paths limit when flushing asynchronous inserts

6 participants