Repository navigation
Fix exception when reading a dynamic subcolumn through a Buffer table - #111948
Conversation
`StorageBuffer::read` compared the structure of the destination table with its own structure by looking the requested columns up in the enumerated lists of columns of both tables, and dereferenced the result of `NamesAndTypesList::tryGetByName` without checking it. Dynamic subcolumns - paths inside a `JSON` or a `Dynamic` column - cannot be enumerated, so they are absent from these lists, and reading such a subcolumn through a `Buffer` table aborted the server on the disengaged `std::optional`: `libc++ Hardening assertion this->has_value() failed: optional operator-> called on a disengaged value`. For the same reason, when a dynamic subcolumn was missing in the enumerated columns of the destination table, it was considered absent there, and the data of the destination table was silently skipped, so the query returned only the rows still kept in the buffers. Resolve such columns by name in the corresponding storage snapshot, which handles dynamic subcolumns, and add the requested dynamic subcolumns to the header used for the conversion between the structures. Found by BuzzHouse: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100391&sha=e252b917d11278bbbaf787c0d2214f0bbfec2767&name_0=PR&name_1=BuzzHouse%20%28amd_tsan%29 Related: #100391
|
Workflow [PR], commit [be8b42d] Summary: ✅
AI ReviewSummaryThis PR fixes Final Verdict✅ No blocking or major findings. |
…dynamic-subcolumn-crash
… the test The first half of `04647_buffer_dynamic_subcolumn` deliberately gives the `Buffer` table a structure that differs from its destination table, and `StorageBuffer::read` reports every such difference with a warning: `Destination table ... has different type of column ...`. `clickhouse-test` runs the client with `--send_logs_level=warning`, so these warnings ended up on the client's stderr and the test failed in `Fast test` with `Reason: having stderror`. Suppress them with `SET send_logs_level = 'fatal'`, the same way `00158_buffer_and_nonexistent_table` suppresses the analogous warning. https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111948&sha=36424d5aaee96649efe19e434922d6ff5c764a72&name_0=PR&name_1=Fast%20test
…dynamic-subcolumn-crash
|
Both CI failures on
@groeneai, please investigate #110518 (report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111948&sha=e99a507ad694189837906329d3f49d1e698b772c&name_0=PR&name_1=Stateless%20tests%20%28amd_llvm_coverage%2C%20ParallelReplicas%2C%20s3%20storage%2C%20parallel%29) and provide a fix in a separate PR; if a fix is already in progress, link it there. Merged |
|
There is a fix in progress for #110518: #111689 ( The logs of this job confirm it is the same defect. In The coordinator logs exactly three lines for that query: coordinator created, replica 0 set as the snapshot replica, and the ignored announcement from replica 1. The initiator never announced, because the exact-count short-circuit replaced its #111689 extracts the announcement into One detail worth recording on the issue: no declared projection is required. The inner table of Rate over the last 7 days for the message signature: 92 hits across 82 distinct pull requests, plus 4 on master, so it is unrelated to this branch. Your attribution of the |
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 39/39 (100.00%) · Uncovered code |
|
Thanks — noted, my "no fix yet" was out of date: #111689 ( Current state of this PR: CI on |
alexey-milovidov
left a comment
There was a problem hiding this comment.
This is great!
Reading a dynamic subcolumn - a path inside a
JSONor aDynamiccolumn - through aBuffertable led to an exception, becauseStorageBuffer::readdereferenced the result ofNamesAndTypesList::tryGetByNamewithout checking it: such subcolumns cannot be enumerated, so they are absent from the enumerated lists of columns of theBuffertable and of its destination table.For the same reason, a dynamic subcolumn was considered absent in the destination table, and the data of the destination table was silently skipped, so the query returned only the rows still kept in the buffers.
Such columns are now resolved by name in the corresponding storage snapshot, which handles dynamic subcolumns, and the requested dynamic subcolumns are added to the header used for the conversion between the structures of the two tables.
Found by BuzzHouse in the CI of an unrelated pull request: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=100391&sha=e252b917d11278bbbaf787c0d2214f0bbfec2767&name_0=PR&name_1=BuzzHouse%20%28amd_tsan%29
Related: #100391
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fix an exception and silently skipped data when reading a dynamic subcolumn (a path inside a
JSONor aDynamiccolumn) through aBuffertable.