Repository navigation
Fix REPLACE PARTITION waiting for mutations/merges on unrelated partitions - #59138
alexey-milovidov merged 43 commits into
Conversation
|
@alexey-milovidov could you please take a look or assign anyone to do it? P.S. I had to create a new PR since I wasn't able to re-open the old. |
|
This is an automated comment for commit b04aa50 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
|
|
Tests have failed. |
…tion_stop_the_world
fixes readability-redundant-access-specifiers warning
| $CLICKHOUSE_CLIENT -nq "OPTIMIZE TABLE t1 PARTITION id '1' DEDUPLICATE BY p;" & | ||
| merge_pid=$! | ||
|
|
||
| sleep 0.1 && echo "Give the server a moment to start merge" |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
| } | ||
| }; | ||
|
|
||
| // TODO: remove this before merging |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
|
Only failing test is:
|
|
CI is green, and looks like the .sh test is stable -- it did not fail in the latest CI runs |
|
Thank you! I'm very eager to merge... but I don't see who checked/read this code. |
…top_the_world Fix REPLACE PARTITION waiting for mutations/merges on unrelated partitions
…e_parition_waiting 24.8 Backport of ClickHouse#59138 - Fix `REPLACE PARTITION` waiting for mutations/merges on unrelated partitions
…top_the_world Fix REPLACE PARTITION waiting for mutations/merges on unrelated partitions
…s_without_written_blocks 24.3 Backport of ClickHouse#77766 and ClickHouse#59138 - Stop merges without written blocks / Fix REPLACE PARTITION waiting for mutations/merges on unrelated partitions
The `merges_blocker` `ActionLock` in `replacePartitionFrom` was scoped inside the `if/else` block and destroyed before the actual partition replacement, allowing background mutations to start on parts in the target partition. A mutation could then complete on an already-removed part and add a new version back to the working set, "resurrecting" old data alongside the new data from `REPLACE PARTITION`. Move the `merges_blocker` to function scope so it stays alive until `replacePartitionFrom` returns. The bug was introduced in #59138. Closes #73783 Co-Authored-By: Claude Opus 4.6 <[email protected]>
|
Hi @Enmk @alexey-milovidov — while reviewing this PR I found the following:
Happy to discuss — close anything that's wrong or already addressed. |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
ALTER TABLE .. REPLACE PARTITIONdoesn't wait anymore for mutations/merges that happen in other partitionsAdd 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 PARTITIONwaits 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 PARTITIONonly 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
REPLACEis relatively simple, there is a high chance that merges and mutations are re-allowed relatively fast.Related: #45335
Continuation of: #54272