Repository navigation
Fix crash in ProtobufRowInputFormat when a valid row precedes a bad row - #107739
alexey-milovidov merged 8 commits into
Conversation
Follow-up to ClickHouse#106905. After a parse error, destroyReaderAndSerializer nulls the serializer and the next readRow recreates it. setColumns was only called when row_num == 0, so when a valid row had already been appended to the block (row_num > 0), the freshly recreated serializer kept null column pointers and threw an exception (in the debug build, SIGSEGV in release) inside ProtobufSerializer::readRow. Call setColumns whenever the serializer was just (re)created, not only at the start of a block. Closes ClickHouse#107644
|
Workflow [PR], commit [e8b48f8] Summary: ✅
AI ReviewSummaryThis PR fixes Final VerdictStatus: ✅ Approve |
|
@alexey-milovidov Can we merge this PR? Don't think performance failures related to my change, it fails both old/new on TSV format |
…umns-after-recovery
Address review feedback (prefer functional tests over unit tests): drop the `ValidRowBeforeBadRowRecovery` gtest added for this fix and add an equivalent stateless functional test `04409_protobuf_skip_bad_row_after_valid`. The test feeds a length-delimited Protobuf stream of valid, bad, valid messages into `INSERT ... FORMAT Protobuf` with `input_format_allow_errors_num` and checks that the bad message is skipped and both valid rows are inserted. Without the fix the server crashes (SIGSEGV) in `ProtobufSerializer::readRow`; the crash was verified to reproduce on the current build and the test passes with the fix. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
…umns-after-recovery
|
Merged fresh `master` into the branch to retrigger CI. The previous run on `2ba39bb6` showed a long list of red jobs, but these were all the second-wave jobs (extended builds, stress, performance, full integration) that never started — the whole workflow run was cancelled at No code change was needed: the merge is clean (master only touched the embedded docs in |
|
Status after re-checking the fresh CI run on
No code change was warranted. Ready to merge once the in-progress jobs settle; the red stress check is the #107941 flake and can be merged through. |
|
The two red jobs on Evidence:
Everything else is green: all @groeneai, FYI — these two |
|
Update — the second-wave jobs that were still in progress at the time of the previous status comment (coverage stateless,
Final tally on this head: 150 success, 18 skipped, 2 failure — the only two reds are the same So the PR is now in the merge-ready state described above: |
…umns-after-recovery
…umns-after-recovery
The CI flaky check maps a changed fixture under `format_schemas/` back to the tests that textually reference its filename; when no test contains the literal `04409_protobuf_skip_bad_row_after_valid.proto`, it falls back to running every `04409_*` test. That made the flaky check (and the CH Inc sync run) repeatedly execute the unrelated, heavy `04409_filesystem_cache_reserve_granularity`, which fails with "Test runs too long" under ASan: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107739&sha=b37d1cc3dbb68cb2c2e3f82de590b84d0e79e2bd&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20flaky%20check%29 Using the explicit extension in `format_schema` is already common in the test suite and makes the fixture-to-test mapping precise. Co-Authored-By: Claude Fable 5 <[email protected]>
…its owning test `_tests_owning_data_file` maps a changed auxiliary file (e.g. a `format_schemas/*.proto` schema) back to the tests that reference it, and falls back to running every same-number-prefix test when no candidate references the literal filename. Format schemas are conventionally referenced without the extension (`format_schema = 'NNNNN_foo:Message'`), so any PR adding a schema fixture hit the fallback and the flaky check ran unrelated sibling tests. Seen on PR ClickHouse#107739, where the flaky check ran the heavy, unrelated `04409_filesystem_cache_reserve_granularity` (prefix sibling of the PR's own test) and failed with "Test runs too long": https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107739&sha=b37d1cc3dbb68cb2c2e3f82de590b84d0e79e2bd&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20flaky%20check%29 Also match the extensionless stem: candidates are already narrowed to the fixture's five-digit prefix, so the stem is still an unambiguous reference. Co-Authored-By: Claude Fable 5 <[email protected]>
…umns-after-recovery
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 11/11 (100.00%) · Uncovered code |
…valid row precedes a bad row
Backport #107739 to 26.6: Fix crash in ProtobufRowInputFormat when a valid row precedes a bad row
Backport #107739 to 26.7: Fix crash in ProtobufRowInputFormat when a valid row precedes a bad row
|
Hi @atsarevskiy @alexey-milovidov — a couple of suggestions to make this PR easier for reviewers and the changelog reader. Description (currently
Ignore this if the current title/body is intentional. |
Backport #107739 to 26.5: Fix crash in ProtobufRowInputFormat when a valid row precedes a bad row
Backport #107739 to 26.3: Fix crash in ProtobufRowInputFormat when a valid row precedes a bad row
…-contained The functional test added by #107739 (`04409_protobuf_skip_bad_row_after_valid`) crashed with `SIGSEGV` on `25.8` because the prerequisite fix from #106905 is missing on this branch: its backport #107627 was closed without merging, so `25.8` still has void ProtobufRowInputFormat::syncAfterError() { reader->endMessage(true); } After a parse error, `readRow`'s catch block calls `destroyReaderAndSerializer`, which nulls `reader`. `IRowInputFormat::read` then calls `syncAfterError`, which dereferences the null `reader` -> `SIGSEGV`. The `setColumns` fix backported here is therefore necessary but not sufficient on `25.8`. Cherry-pick the `ProtobufRowInputFormat.cpp` part of #106905 (`cda04909d946c83546b4a9073ddf7032e9616669`): resync via `endMessage(true)` inside `readRow`'s catch while `reader` is still alive, make `syncAfterError` a no-op, and restrict `allowSyncAfterError` to the length-delimited case. The resulting `readRow` / `syncAfterError` / `allowSyncAfterError` logic is now byte-identical to `master`. The unit test from #106905 is not carried over: `25.8` has no `src/Processors/Formats/Impl/tests` directory, and the functional test `04409_protobuf_skip_bad_row_after_valid` already covers this path. Original pull-request: #107739 Prerequisite pull-request: #106905 Related: #107627 CI report: https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=111910&sha=latest&name_0=BackportPR&name_1=Stateless%20tests%20(amd_asan%2C%20distributed%20plan%2C%20parallel%2C%202%2F2) Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Backport #107739 to 25.8: Fix crash in ProtobufRowInputFormat when a valid row precedes a bad row
…at when a valid row precedes a bad row
…at when a valid row precedes a bad row
…at when a valid row precedes a bad row
…tcolumns-after-recovery Fix crash in ProtobufRowInputFormat when a valid row precedes a bad row
…its owning test `_tests_owning_data_file` maps a changed auxiliary file (e.g. a `format_schemas/*.proto` schema) back to the tests that reference it, and falls back to running every same-number-prefix test when no candidate references the literal filename. Format schemas are conventionally referenced without the extension (`format_schema = 'NNNNN_foo:Message'`), so any PR adding a schema fixture hit the fallback and the flaky check ran unrelated sibling tests. Seen on PR ClickHouse#107739, where the flaky check ran the heavy, unrelated `04409_filesystem_cache_reserve_granularity` (prefix sibling of the PR's own test) and failed with "Test runs too long": https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=107739&sha=b37d1cc3dbb68cb2c2e3f82de590b84d0e79e2bd&name_0=PR&name_1=Stateless%20tests%20%28amd_asan_ubsan%2C%20flaky%20check%29 Also match the extensionless stem: candidates are already narrowed to the fixture's five-digit prefix, so the stem is still an unambiguous reference. Co-Authored-By: Claude Fable 5 <[email protected]>
PROTO: Protobuf with allow_errors, a valid message then a bad one -> crash. Effect in the production build a394e92: its upstream test(s) 04409_protobuf_skip_bad_row_after_valid fail on it and pass on official 26.8.8.8, run on isolated servers (evidence/fix_ci_20260925/upstream_repro/server_triage_PROD263_vs_UP2688.tsv). Upstream patch unchanged, with its test(s): 04409_protobuf_skip_bad_row_after_valid. Co-Authored-By: Claude Opus 5.5 <[email protected]>
PROTO: ProtobufRowInputFormat with input_format_allow_errors_num/ratio: after a parse error, readRow destroyed the reader and IRowInputFormat then called syncAfterError, which dereferenced the null reader -> crash. Dependency of the ClickHouse#107739 backport (50b1854): the 26.3 branch had this fix (e6675f6, 2026-06-16) before ClickHouse#107739 (1c4cb1f, 2026-07-25), and the fork's v26.3.12.3 base predates it. Found by the CAND4 release gate: the ClickHouse#107739 test 04409_protobuf_skip_bad_row_after_valid crashed CAND4 (e7432ca) with SIGSEGV in ProtobufReader::endMessage via IRowInputFormat::read (evidence/fix_ci_20260925/release_cand4/logs/). Upstream patch unchanged (hunks at an 8-line offset because of ClickHouse#107739), with its gtest gtest_protobuf_sync_after_error.cpp; the stateless test is ClickHouse#107739's 04409. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Closes: #107644
Related: #106905
Description
Follow-up to #106905.
INSERT ... FORMAT Protobufwithinput_format_allow_errors_num > 0still crashed the server (SIGSEGV) when one or more valid messages were read before a bad (skippable) message in the same block.After a parse error,
readRow's catch block callsdestroyReaderAndSerializer, which nulls the serializer, and the nextreadRowrecreates it. ButsetColumnswas only called whenrow_num == 0. When a valid row had already been appended to the block (row_num > 0), the freshly recreated serializer kept null column pointers and dereferenced them inProtobufSerializer::readRow— an exception in the debug build, SIGSEGV at address0x18in release.The fix calls
setColumnswhenever the serializer was just (re)created, not only at the start of a block. Adds a gtest (ValidRowBeforeBadRowRecovery) that reproduces the crash (valid → bad → valid) and passes with the fix.Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix server crash (SIGSEGV) when reading Protobuf data with
input_format_allow_errors_num > 0and a valid message precedes a bad (skippable) message in the same block.Documentation entry for user-facing changes
Version info
26.7.2.18,26.6.2.115,26.5.6.75,26.3.17.77,25.8.29.38