Skip to content

Backport #107739 to 25.8: Fix crash in ProtobufRowInputFormat when a valid row precedes a bad row - #111910

Merged
alexey-milovidov merged 2 commits into
25.8from
backport/25.8/107739
Jul 29, 2026
Merged

alexey-milovidov merged 2 commits into
25.8from
backport/25.8/107739

Conversation

@robot-clickhouse

@robot-clickhouse robot-clickhouse commented Jul 25, 2026 •

Copy link
Copy Markdown
Member

Original pull-request #107739

This pull-request is a last step of an automated backporting.
Treat it as a standard pull-request: look at the checks and resolve conflicts.
Merge it only if you intend to backport changes to the target branch, otherwise just close it.

Additional change on top of the automated backport

The automated cherry-pick alone was not sufficient on 25.8: the functional test it
brings (04409_protobuf_skip_bad_row_after_valid) crashed with SIGSEGV, because the
prerequisite fix from #106905 is missing on
this branch — its backport #107627 was closed
without merging. So 25.8 still had:

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.

Therefore the ProtobufRowInputFormat.cpp part of #106905 is cherry-picked here as well
(resync via endMessage(true) inside readRow's catch while reader is still alive,
syncAfterError becomes a no-op, allowSyncAfterError restricted to the length-delimited
case). The readRow / syncAfterError / allowSyncAfterError logic is now 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 already covers this
path.

Related: #106905
Related: #107627

The PR source

The PR is created in the CI job

Version info

  • Merged into: 25.8.29.38

@robot-clickhouse robot-clickhouse added pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-critical-bugfix labels Jul 25, 2026
@clickhouse-gh

clickhouse-gh Bot commented Jul 25, 2026 •

Copy link
Copy Markdown
Contributor

Workflow [BackportPR], commit [2d5ba53]

…-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]>
@alexey-milovidov

Copy link
Copy Markdown
Member

The two Integration tests (amd_tsan, 1/6) failures — test_async_load_databases/test.py::test_materialized_views_cascaded_multiple and ::test_materialized_views_replicated — are unrelated to this backport (it touches only ProtobufRowInputFormat) and are tracked by the open 25.8-specific issue #108914 (fix #107119 not backported to 25.8).

@groeneai, please investigate #108914 and provide the missing 25.8 backport of #107119 in a separate PR. If a fix is already in progress, please link it here.

The remaining two reds were caused by the backport itself and are addressed by 2d5ba5318d1: the Stateless tests (amd_asan, distributed plan, parallel, 2/2) SIGSEGV in 04409_protobuf_skip_bad_row_after_valid (and, most likely, the Stress test (amd_tsan) Killed by signal from the same test) came from the missing prerequisite #106905 on 25.8 — see the updated description.

@groeneai

Copy link
Copy Markdown
Collaborator

The #107119 backport to 25.8 already exists: you merged it yourself as #108917 on 2026-07-01 (3e51fbdaf518). It is on 25.8 today, so there is nothing to open and nothing in progress.

But it did not fix these two tests, and #108914 is stale in naming #107119 as the whole gap. Counting only the 25.8 base branch, the two tests are 396 OK / 36 FAIL both before and after that merge, with post-merge failures from 2026-07-06 through 2026-07-24. The residual has a different signature: instead of the 900s pytest session timeout #107119 addressed, the failures now take 270ms and ~20s and are two plain assertion failures. Your #111910 run (73928c1, Integration tests (amd_tsan, 1/6)) shows exactly these:

  • test_materialized_views_cascaded_multiple at test.py:336: assert '42,0\n' == '42,2\n' (the cascaded MV read the not-yet-populated test_mv.x).
  • test_materialized_views_replicated: Code: 82. DB::Exception: Database test_mv already exists. This is fallout, not an independent bug: cascaded_multiple aborts at its assertion before reaching its own drop database test_mv sync, and replicated then does a bare CREATE DATABASE test_mv.

The actual missing change is @ azat's #88573 ("test: fix flakiness of test_async_load_databases (pushing to MV reordered and lack of proper cleanup)"), merged to master on 2025-10-15. It is absent from 25.8 because the branch point is 2025-08-25, and its two commits are precisely the two symptoms above:

  • 703f510b77da adds settings={"max_threads": 1} to the insert into test_mv.t values(42) in cascaded_multiple, so pushing to the MVs is not reordered. That is the 42,2 assertion.
  • 764bb3462470 adds drop database if exists preambles (test_mv in three tests plus DROP DATABASE IF EXISTS test_mv in replicated, and a/lazy in test_dependent_tables), making the tests repeatable after an earlier abort. That is the already exists error.

master confirms it: these tests are 24738 OK / 0 FAIL over the last 45 days.

Both commits cherry-pick onto current 25.8 (b889bdd61bbe) with no conflict, test-file only. On mechanism I would rather not hand-author it: @ pufit's standing instruction to me is never to create manual release-branch backport PRs, and #102944 and #102946 were closed on that basis. Labelling #88573 with v25.8-must-backport produces a robot PR the same way #111910 itself was produced, and I cannot apply the label. If you would prefer I open the PR by hand anyway, say so and I will.

I will update #108914 to point at #88573 rather than #107119.

@alexey-milovidov

Copy link
Copy Markdown
Member

Thank you — your analysis is right, and the residual is indeed #88573 rather than #107119.

No need to hand-author anything: I have applied the v25.8-must-backport label to #88573, so the robot will produce the 25.8 backport the same way it produced this PR. @pufit's instruction stands; please keep using the label route via me.

Please do update #108914 to point at #88573.

This PR itself is now fully green on 2d5ba531 (32 checks, 0 failures) — the 04409_protobuf_skip_bad_row_after_valid SIGSEGV and the Stress test (amd_tsan) red both cleared with the #106905 prerequisite cherry-pick, and the test_async_load_databases integration tests passed in the latest run.

@groeneai

Copy link
Copy Markdown
Collaborator

Understood on the mechanism: label route via you, no hand-authored backports. Noted for future release-branch gaps.

#108914 is updated: retitled to name #88573 as the gap, body rewritten with the evidence, and pointed at #112013. #108914 (comment)

#112013 checks out on inspection. Its diff is one file, +10 / -1, and its added and removed line sets are identical to d2c395b492f54 on master, so nothing was adapted. The resulting test.py at 239917f4 parses and carries both #88573's markers (max_threads 1, drop database if exists test_mv 4) and the earlier #108917 ones (insert_phase_deadline 2, wait(180) 1, timeout=60 2), so the two backports compose. No prerequisite gap of the #106905 kind: #88573 touches only that test file and neither of its two commits depends on server-side behaviour that 25.8 lacks. I am watching its CI, specifically Integration tests (amd_tsan, 1/6), and will flag anything in that thread rather than pushing to the robot's branch.

One extra data point that arrived while checking: the branch partition is total. Reading test.py at every active release ref and counting #88573's two markers, 25.8 has 0 and 0 while 25.12, 26.2 through 26.7 and master all have 1 and 4. Over 45 days of Integration tests% on those refs, 25.8 is 146 OK / 28 FAIL and every branch carrying the change is 0 FAIL (master 6114 OK). So 25.8 was the only exposed branch and #112013 closes the last one.

@alexey-milovidov
alexey-milovidov merged commit 19fd660 into 25.8 Jul 29, 2026
34 checks passed
@alexey-milovidov
alexey-milovidov deleted the backport/25.8/107739 branch July 29, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backport Changes, backported to release branch. Do not use manually - automated use only! pr-critical-bugfix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants