Skip to content

Improve updating mutations - #87206

Merged
alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
k-morozov:improve_update_mutations
Oct 18, 2025
Merged

alexey-milovidov merged 2 commits into
ClickHouse:masterfrom
k-morozov:improve_update_mutations

Conversation

@k-morozov

@k-morozov k-morozov commented Sep 16, 2025 •

Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • Not for changelog

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

Slightly improve the code around updating mutations.

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)
  1. Reduce calls to MergeTreePartInfo::fromPartName.
  2. Modify QueueRepresentation data structure to minimize queue traversal.

@k-morozov k-morozov changed the title [WIP] Improve updating mutations Improve updating mutations Sep 25, 2025
@k-morozov
k-morozov marked this pull request as ready for review September 25, 2025 10:27
@alexey-milovidov alexey-milovidov added the can be tested Allows running workflows for external contributors label Oct 16, 2025

@alexey-milovidov alexey-milovidov left a comment

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.

This is a good change.

@alexey-milovidov alexey-milovidov self-assigned this Oct 17, 2025
@clickhouse-gh

clickhouse-gh Bot commented Oct 17, 2025 •

Copy link
Copy Markdown
Contributor

Workflow [PR], commit [167311d]

Summary: ❌

job_name test_name status info comment
Integration tests (amd_binary, 4/5) failure
test_refreshable_mat_view/test.py::test_long_query_cancel FAIL cidb
Integration tests (amd_tsan, 1/6) failure
test_storage_s3_queue/test_parallel_inserts.py::test_parallel_inserts_with_failures[1] FAIL cidb
Stress test (amd_tsan) failure
Server died FAIL cidb
Hung check failed, possible deadlock found (see hung_check.log) FAIL cidb
Killed by signal (in clickhouse-server.log) FAIL cidb
Fatal message in clickhouse-server.log (see fatal_messages.txt) FAIL cidb
Killed by signal (output files) FAIL cidb
Found signal in gdb.log FAIL cidb

@clickhouse-gh clickhouse-gh Bot added the pr-not-for-changelog This PR should not be mentioned in the changelog label Oct 17, 2025
@alexey-milovidov
alexey-milovidov merged commit 11e7f7b into ClickHouse:master Oct 18, 2025
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-synced-to-cloud The PR is synced to the cloud repo label Oct 18, 2025
pull Bot pushed a commit to SINHASantos/ClickHouse that referenced this pull request Aug 21, 2026
…ecated syntax

A table created with the deprecated positional syntax
(ENGINE = ReplicatedMergeTree(date, key, granularity) under
allow_deprecated_syntax_for_merge_tree) uses date-based V0 part names.
MergeTreePartInfo::getPartNameAndCheckFormat cannot produce such a name,
because getPartNameV0 needs the min/max DayNum that MergeTreePartInfo does
not carry, so it throws BAD_DATA_PART_NAME unconditionally.

Two ActiveDataPartSet entry points accept only a MergeTreePartInfo and must
therefore synthesize a name that way: tryAddPart and add(info, Strings *).
Each had exactly one production caller, and both callers already held the
part name and discarded it:

  * ReplicatedMergeTreeQueue::getPartNamesToMutate builds mutation.parts_to_do.
    The throw aborted mutationsUpdatingTask and left parts_to_do empty, so the
    mutation was reported as done on a replica that had not applied it. With
    mutations_sync = 2 the ALTER returned success while that replica still
    served pre-mutation values. Regressed by ClickHouse#87206, which changed
    QueueEntryRepresentation::produced_parts from a vector of names to a vector
    of infos.

  * StorageReplicatedMergeTree::checkPartsImpl builds the set of empty
    unexpected parts on disk. The throw aborted ReplicatedMergeTreeAttachThread
    and left the table readonly. Regressed by ClickHouse#103537, which replaced
    tryAdd(name, &reason) with add(info, name, ...).

Both failures appear in a single Upgrade check report on ClickHouse#112457. Pass the
name that is already in hand at both call sites instead. V0 name formatting is
untouched, and behaviour on current-format tables is provably unchanged
because the name-taking overload re-parses the name into the identical info
and runs the same addImpl. This is the remedy alexey-milovidov used in
536b611 for the ATTACH PARTITION instance of
the same defect, which added ActiveDataPartSet::tryAdd(const String &).

dropped_parts is deliberately left holding infos only:
removePartAndCoveredParts(info) is getPartsCoveredBy + remove, neither of
which regenerates a name.

The V0 gap in MergeTreeData::restorePartFromBackup that the comment at the
throw site describes is a different code path, absent from both stacks here,
and is not addressed.

Testing: 04907_mutation_parts_to_do_deprecated_syntax asserts parts_to_do on
the frozen replica and fails on master with "parts to do 0". checkPartsImpl's
state requires fabricating parts on disk, which is not allowed in a stateless
test, so that half is covered by three V0 cases in gtest_active_data_part_set,
all of which fail with this change reverted.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

can be tested Allows running workflows for external contributors 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.

3 participants