Skip to content

Fix REPLACE PARTITION waiting for mutations/merges on unrelated partitions - #54272

Closed
Enmk wants to merge 17 commits into
ClickHouse:masterfrom
Enmk:fix_replace_partition_stop_the_world
Closed

Enmk wants to merge 17 commits into
ClickHouse:masterfrom
Enmk:fix_replace_partition_stop_the_world

Conversation

@Enmk

@Enmk Enmk commented Sep 4, 2023 •

Copy link
Copy Markdown
Contributor

Changelog category (leave one):

  • Improvement

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

ALTER TABLE .. REPLACE PARTITION doesn't wait anymore for mutations/merges that happen in other partitions

Documentation entry for user-facing changes

  • Documentation is written (mandatory for new features)

Add a user-readable short description of the changes that should be added to docs.clickhouse.com below.
On a big table with lots of parts/partitions and lots of merges/mutations scheduled on a table, ALTER TABLE .. REPLACE PARTITION waits very long until all of those finish, even if the target partition is not affected by those merges and/or mutations. This leads to poor maintenance experience.

With this improvement, ALTER TABLE .. REPLACE PARTITION only waits for merges/mutations to the target partition, greatly reducing up the waiting period.

Technically this stops the merges on all partitions and prevents new ones from starting, rather than stopping merges on the target partition only. But since REPLACE is relatively simple, there is a high chance that merges and mutations are re-allowed relatively fast.

Related: #45328

@Enmk
Enmk marked this pull request as draft September 4, 2023 18:24
@robot-ch-test-poll4 robot-ch-test-poll4 added the pr-improvement Pull request with some product improvements label Sep 5, 2023
@robot-ch-test-poll4

robot-ch-test-poll4 commented Sep 5, 2023 •

Copy link
Copy Markdown
Contributor

This is an automated comment for commit 58e8857 with description of existing statuses. It's updated for the latest CI running

❌ Click here to open a full report in a separate page

Successful checks
Check nameDescriptionStatus
Push to DockerhubThe check for building and pushing the CI related docker images to docker hub✅ success
Check nameDescriptionStatus
CI runningA meta-check that indicates the running CI. Normally, it's in success or pending state. The failed status indicates some problems with the PR⏳ pending
Fast testNormally this is the first check that is ran for a PR. It builds ClickHouse and runs most of stateless functional tests, omitting some. If it fails, further checks are not started until it is fixed. Look at the report to see which tests fail, then reproduce the failure locally as described here❌ failure
Mergeable CheckChecks if all other necessary checks are successful❌ failure
Style CheckRuns a set of checks to keep the code style clean. If some of tests failed, see the related log from the report❌ failure

@tavplubix tavplubix added the can be tested Allows running workflows for external contributors label Sep 5, 2023

bool checkOperationIsNotCanceled() const
{
if (merges_blocker->isCancelledForPartition(new_data_part->info.partition_id)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I assume here that the merge operation doesn't create parts in other partitions, so we might check only if the destination partition was canceled or not.


bool MergeTask::GlobalRuntimeContext::isCancelled() const
{
return merges_blocker->isCancelledForPartition(future_part->part_info.partition_id)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I assume here that the merge operation doesn't create parts in other partitions, so we might check only if the destination partition was canceled or not.

@alexey-milovidov

Copy link
Copy Markdown
Member

It failed with a segmentation fault because your code is not memory-safe.

@alexey-milovidov alexey-milovidov removed the can be tested Allows running workflows for external contributors label Sep 23, 2023
@alexey-milovidov alexey-milovidov self-assigned this Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-improvement Pull request with some product improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants