Skip to content

Cherry pick #101292 to 26.4: Fix UBSan in MergeTreeDataPartWriterCompact::cancel - #103697

Merged
robot-ch-test-poll1 merged 25 commits into
backport/26.4/101292from
cherrypick/26.4/101292
May 6, 2026
Merged

robot-ch-test-poll1 merged 25 commits into
backport/26.4/101292from
cherrypick/26.4/101292

Conversation

@robot-clickhouse-ci-1

Copy link
Copy Markdown
Contributor

Original pull-request #101292

Do not merge this PR manually

This pull-request is a first step of an automated backporting.
It contains changes similar to calling git cherry-pick locally.
If you intend to continue backporting the changes, then resolve all conflicts if any.
Otherwise, if you do not want to backport them, then just close this pull-request.

The check results does not matter at this step - you can safely ignore them.

Troubleshooting

If the conflicts were resolved in a wrong way

If this cherry-pick PR is completely screwed by a wrong conflicts resolution, and you want to recreate it:

  • delete the pr-cherrypick label from the PR
  • delete this branch from the repository

You also need to check the Original pull-request for pr-backports-created label, and delete if it's presented there

The PR source

The PR is created in the CI job

alexey-milovidov and others added 24 commits March 30, 2026 03:16
`streams_by_codec` can contain null entries when `addStreams` partially
fails: `std::map::operator[]` value-initializes (inserts null) before
`std::make_shared<CompressedStream>` runs, and if the allocation throws,
the null entry persists. When `cancel` is later called (e.g. from the
background executor's catch block), iterating and dereferencing these
null entries is undefined behavior caught by UBSan.

Add a null guard, consistent with the base class
`MergeTreeDataPartWriterOnDisk::cancel` which already guards its
optional stream pointers.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…ll check

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…` as `long`, `no-flaky-check`

These tests consistently exceed the flaky check time limit.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
…0091_union_race_conditions_2`

These tag-only changes (`long`, `no-flaky-check`) were unrelated to the
UBSan fix and triggered bugfix-validation failures because the modified
tests don't catch the bug being fixed. Move them to a separate PR.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…xception

Adds a `compact_part_writer_fail_in_add_streams` failpoint and a SQL
test that forces `addStreams` to throw mid-merge. Without the fix, the
old `streams_by_codec[codec_id]` `operator[]` would have left a null
`shared_ptr` in the map, so `cancel` (which iterates the map and calls
`stream->cancel`) would dereference a null pointer.

The test follows the same pattern as
`04077_wide_part_writer_cancel_on_exception.sql`.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…riter-cancel

# Conflicts:
#	src/Common/FailPoint.cpp
…ancel

Fix UBSan in MergeTreeDataPartWriterCompact::cancel
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only! do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default labels Apr 29, 2026
@robot-clickhouse

Copy link
Copy Markdown
Member

Dear @alexey-milovidov, @tuanpach, this cherry-pick PR has not been updated for 3d1h35m0s. Please resolve the conflicts to backport #101292, or close this PR if the backport is no longer needed. This PR will be automatically closed after 7 days of inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do not test disable testing on pull request pr-bugfix Pull request with bugfix, not backported by default pr-cherrypick Cherry-pick of merge-commit before backporting. Do not use manually - automated use only!

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants