Skip to content

Add additional checks for missing streams in Wide parts#92076

Merged
Avogar merged 10 commits intoClickHouse:masterfrom
Avogar:better-check-for-unexpected-streams
Dec 29, 2025
Merged

Add additional checks for missing streams in Wide parts#92076
Avogar merged 10 commits intoClickHouse:masterfrom
Avogar:better-check-for-unexpected-streams

Conversation

@Avogar
Copy link
Member

@Avogar Avogar commented Dec 12, 2025

Changelog category (leave one):

  • Not for changelog (changelog entry is not required)

Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):

If some files in data part are missing, we can end up with inconsistent in-memory state of some columns which can lead to crashes. It's better to throw logical errors in this case

@clickhouse-gh
Copy link
Contributor

clickhouse-gh bot commented Dec 12, 2025

Workflow [PR], commit [e5e5426]

Summary:

job_name test_name status info comment
Stateless tests (amd_binary, ParallelReplicas, s3 storage, parallel) failure
02319_lightweight_delete_on_merge_tree FAIL cidb, issue ISSUE EXISTS
Stateless tests (amd_debug, distributed plan, s3 storage, parallel) failure
02319_lightweight_delete_on_merge_tree FAIL cidb, issue ISSUE EXISTS
Integration tests (arm_binary, distributed plan, 1/4) failure
test_s3_plain_rewritable/test.py::test[cache_s3_plain_rewritable-data/] FAIL cidb, issue ISSUE EXISTS
BuzzHouse (amd_debug) failure
Logical error: 'Inconsistent AST formatting: the query: (STID: 1941-1bfa) FAIL cidb, issue ISSUE EXISTS
BuzzHouse (arm_asan) failure
Logical error: Function writeSlice expects same column types for GenericArraySlice and GenericArraySink. (STID: 3276-468b) FAIL cidb IGNORED

@clickhouse-gh clickhouse-gh bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Dec 12, 2025
@azat azat self-assigned this Dec 14, 2025
@Avogar Avogar requested a review from azat December 19, 2025 14:13
@azat
Copy link
Member

azat commented Dec 21, 2025

Hm, there are still some issues - https://s3.amazonaws.com/clickhouse-test-reports/json.html?PR=92076&sha=latest&name_0=PR&name_1=Stateless+tests+%28amd_asan%2C+distributed+plan%2C+parallel%2C+2%2F2%29

Logical error: Stream A for column B is not found (STID: 3190-622d)

@Avogar
Copy link
Member Author

Avogar commented Dec 23, 2025

Tests are good now

if (null_map->size() != nested_column->size())
throw Exception(
ErrorCodes::INCORRECT_DATA,
settings.native_format ? ErrorCodes::INCORRECT_DATA : ErrorCodes::LOGICAL_ERROR,
Copy link
Member

@azat azat Dec 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, why it is OK (INCORRECT_DATA over LOGICAL_ERROR) for native format? (here and below)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because user can try to read corrupted data in Native format and we don't want to throw LOGICAL_ERROR when we try to read some corrupted user data.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But these functions can be called only for Native format? Am I missing something?

I guess native_format == false is when we reading MergeTree data, and in this case we will haveLOGICAL_ERROR with this patch, and for Native over network it will be INCORRECT_DATA?

(Note, StorageMemory also uses NativeReader which will use INCORRECT_DATA as well)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess native_format == false is when we reading MergeTree data, and in this case we will haveLOGICAL_ERROR with this patch, and for Native over network it will be INCORRECT_DATA?

Yes. And over TCP protocol we can also receive some corrupted data in Native format from different language clients.

My intention for these changes is actually to throw logical error in reading from MergeTree, because in serializations we have logic of skipping reading data if returned buffer for some stream is nullptr. And without such checks it may lead to inconsistent in-memory state of the columns and crashes in random places if we have some bug or missing file in the data part.

@Avogar Avogar added this pull request to the merge queue Dec 29, 2025
Merged via the queue into ClickHouse:master with commit 95e809a Dec 29, 2025
125 of 131 checks passed
@Avogar Avogar deleted the better-check-for-unexpected-streams branch December 29, 2025 18:23
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Dec 29, 2025
@Avogar Avogar added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Jan 19, 2026
@robot-ch-test-poll3 robot-ch-test-poll3 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Jan 19, 2026
robot-ch-test-poll1 added a commit that referenced this pull request Jan 19, 2026
Cherry pick #92076 to 25.12: Add additional checks for missing streams in Wide parts
robot-clickhouse added a commit that referenced this pull request Jan 19, 2026
Avogar added a commit that referenced this pull request Jan 21, 2026
Backport #92076 to 25.12: Add additional checks for missing streams in Wide parts
robot-clickhouse added a commit that referenced this pull request Jan 21, 2026
robot-ch-test-poll1 added a commit that referenced this pull request Jan 21, 2026
Cherry pick #92076 to 25.8: Add additional checks for missing streams in Wide parts
robot-clickhouse added a commit that referenced this pull request Jan 21, 2026
robot-ch-test-poll1 added a commit that referenced this pull request Jan 21, 2026
Cherry pick #92076 to 25.10: Add additional checks for missing streams in Wide parts
robot-clickhouse added a commit that referenced this pull request Jan 21, 2026
robot-ch-test-poll1 added a commit that referenced this pull request Jan 21, 2026
Cherry pick #92076 to 25.11: Add additional checks for missing streams in Wide parts
robot-clickhouse added a commit that referenced this pull request Jan 21, 2026
robot-ch-test-poll1 added a commit that referenced this pull request Jan 21, 2026
Cherry pick #92076 to 25.3: Add additional checks for missing streams in Wide parts
@robot-ch-test-poll robot-ch-test-poll added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Jan 21, 2026
Avogar added a commit that referenced this pull request Jan 23, 2026
Backport #92076 to 25.11: Add additional checks for missing streams in Wide parts
clickhouse-gh bot added a commit that referenced this pull request Jan 23, 2026
Backport #92076 to 25.10: Add additional checks for missing streams in Wide parts
clickhouse-gh bot added a commit that referenced this pull request Jan 23, 2026
Backport #92076 to 25.8: Add additional checks for missing streams in Wide parts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore pr-must-backport Pull request should be backported intentionally. Use this label with great care! pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR pr-not-for-changelog This PR should not be mentioned in the changelog pr-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants