Skip to content

Fix bad creation of sparse columns during mutation#92860

Merged
Avogar merged 5 commits intoClickHouse:masterfrom
Avogar:fix-sparse-wide-mutation
Dec 23, 2025
Merged

Fix bad creation of sparse columns during mutation#92860
Avogar merged 5 commits intoClickHouse:masterfrom
Avogar:fix-sparse-wide-mutation

Conversation

@Avogar
Copy link
Copy Markdown
Member

@Avogar Avogar commented Dec 22, 2025

Changelog category (leave one):

  • Bug Fix (user-visible misbehavior in an official stable release)

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

Fix possible error FILE_DOESNT_EXIST after mutation of a sparse column with ratio_of_defaults_for_sparse_serialization=0.0. Closes #92633

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

@Avogar Avogar added the pr-must-backport Pull request should be backported intentionally. Use this label with great care! label Dec 22, 2025
@clickhouse-gh
Copy link
Copy Markdown
Contributor

clickhouse-gh bot commented Dec 22, 2025

Workflow [PR], commit [a663c06]

Summary:

job_name test_name status info comment
Stateless tests (amd_debug, distributed plan, s3 storage, parallel) failure
02346_text_index_parallel_replicas FAIL issue ISSUE EXISTS
BuzzHouse (amd_debug) failure
Logical error: 'Inconsistent AST formatting: the query: (STID: 1941-1bfa) FAIL issue ISSUE EXISTS

@clickhouse-gh clickhouse-gh bot added the pr-bugfix Pull request with bugfix, not backported by default label Dec 22, 2025
@azat azat self-assigned this Dec 22, 2025
…o_setting_bug.sql

Co-authored-by: Azat Khuzhin <a3at.mail@gmail.com>
settings = serialization_infos.getSettings();
settings = SerializationInfo::Settings
{
(*source_part->storage.getSettings())[MergeTreeSetting::ratio_of_defaults_for_sparse_serialization],
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also why serialization_infos.getSettings().ratio_of_defaults_for_sparse initialized with default value (1)? Maybe this should be fixed instead?

Copy link
Copy Markdown
Member Author

@Avogar Avogar Dec 23, 2025

Choose a reason for hiding this comment

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

Also why serialization_infos.getSettings().ratio_of_defaults_for_sparse initialized with default value (1)?

I think to disable Sparse serialization if default settings are used. Maybe just for historical reasons.

Maybe this should be fixed instead?

The main thing here is that serialization_infos.getSettings().ratio_of_defaults_for_sparse will be default always, because we don't serialize this value in serializations.json and during deserialization of it from source part we always use default value. So we need to use value from storage settings always.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks, make sense.
Maybe it make sense to initialize this value from storage for now?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But for bug-fix better to keep patches short, so LGTM

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Maybe it make sense to initialize this value from storage for now?

What do you mean? Propagate value from storage to SerializationInfo deserialization, so we initialize it always with the correct value?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Propagate value from storage to SerializationInfo deserialization, so we initialize it always with the correct value?

Yes

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Well, I am not sure about it. ratio_of_defaults_for_sparse is used only in serialization, not deserialization. And before serialization we usually set fresh values for all settings from the storage settings (as it was here before and as it's done for merge and new parts creation). So ideally we should not use the value of ratio_of_defaults_for_sparse from deserialized SerializationInfo. It was used here because of my mistake only.

@Avogar Avogar added this pull request to the merge queue Dec 23, 2025
Merged via the queue into ClickHouse:master with commit f89fa69 Dec 23, 2025
128 of 131 checks passed
@Avogar Avogar deleted the fix-sparse-wide-mutation branch December 23, 2025 21:03
@robot-clickhouse-ci-1 robot-clickhouse-ci-1 added the pr-must-backport-synced The `*-must-backport` labels are synced into the cloud Sync PR label Dec 23, 2025
robot-ch-test-poll1 added a commit that referenced this pull request Dec 23, 2025
Cherry pick #92860 to 25.10: Fix bad creation of sparse columns during mutation in Wide part
robot-clickhouse added a commit that referenced this pull request Dec 23, 2025
robot-ch-test-poll1 added a commit that referenced this pull request Dec 23, 2025
Cherry pick #92860 to 25.11: Fix bad creation of sparse columns during mutation in Wide part
robot-clickhouse added a commit that referenced this pull request Dec 23, 2025
robot-ch-test-poll1 added a commit that referenced this pull request Dec 23, 2025
Cherry pick #92860 to 25.12: Fix bad creation of sparse columns during mutation in Wide part
robot-clickhouse added a commit that referenced this pull request Dec 23, 2025
@robot-clickhouse robot-clickhouse added the pr-synced-to-cloud The PR is synced to the cloud repo label Dec 23, 2025
clickhouse-gh bot added a commit that referenced this pull request Dec 23, 2025
Backport #92860 to 25.12: Fix bad creation of sparse columns during mutation in Wide part
@azat
Copy link
Copy Markdown
Member

azat commented Dec 23, 2025

Hm, but it can be not only wide parts right? For instance indexes stored as a separate column in compact parts, so after delete index mutation for compact parts we can also have this problem, correct?

@Avogar
Copy link
Copy Markdown
Member Author

Avogar commented Dec 24, 2025

Hm, but it can be not only wide parts right? For instance indexes stored as a separate column in compact parts, so after delete index mutation for compact parts we can also have this problem, correct?

Sounds like yes

@Avogar Avogar changed the title Fix bad creation of sparse columns during mutation in Wide part Fix bad creation of sparse columns during mutation Dec 24, 2025
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-backports-created Backport PRs are successfully created, it won't be processed by CI script anymore label Dec 24, 2025
@Avogar
Copy link
Copy Markdown
Member Author

Avogar commented Dec 24, 2025

Actually, this is incorrect fix. It just hides the real bug. And #92419 didn't introduce it, it just uncovered it using the test 02319_lightweight_delete_on_merge_tree.

https://fiddle.clickhouse.com/e89aeaeb-200d-45c6-9649-e8d70ca2dc71

The problem is: if updated column in source part is Sparse, but in the mutated part is not Sparse (for example due to changed setting to 1.0 that disables sparse serialization), the checksums.txt file of mutated part will still contain files with sparse serialization for some reason (I guess because we copied checksums and didn't updated it or something like that). I will investigate it futher

Avogar added a commit that referenced this pull request Dec 24, 2025
Backport #92860 to 25.11: Fix bad creation of sparse columns during mutation in Wide part
Avogar added a commit that referenced this pull request Dec 24, 2025
Backport #92860 to 25.10: Fix bad creation of sparse columns during mutation in Wide part
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-bugfix Pull request with bugfix, not backported by default 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-synced-to-cloud The PR is synced to the cloud repo

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: 02319_lightweight_delete_on_merge_tree

6 participants