Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 00975_move_partition_merge_tree #30717

Merged
merged 3 commits into from
Oct 27, 2021

Conversation

tavplubix
Copy link
Member

Changelog category (leave one):

  • Bug Fix (user-visible misbehaviour in official stable or prestable release)

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):
Fixed a race condition between REPLACE/MOVE PARTITION and background merge in non-replicated MergeTree that might cause a part of moved/replaced data to remain in partition. Fixes #29327.

Detailed description / Documentation draft:
Previous fix was incorrect, because locking currently_processing_in_background_mutex does not cancel already started merges (and does not fix similar issue with replace partition).

@robot-clickhouse robot-clickhouse added the pr-bugfix Pull request with bugfix, not backported by default label Oct 26, 2021
auto lock1 = lockForShare(local_context->getCurrentQueryId(), local_context->getSettingsRef().lock_acquire_timeout);
auto lock2 = dest_table->lockForShare(local_context->getCurrentQueryId(), local_context->getSettingsRef().lock_acquire_timeout);
auto merges_blocker = stopMergesAndWait();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thank you!
P.S. I though that this will be too much... And by some reason I though that holding currently_processing_in_background_mutex was enough, which is obviously is incorrect, since new part will be commited only when it will be written/renamed.

@@ -1470,6 +1468,7 @@ void StorageMergeTree::movePartitionToTable(const StoragePtr & dest_table, const
transaction.commit(&lock);
}

clearOldMutations(true);
Copy link
Collaborator

Choose a reason for hiding this comment

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

BTW it seems that this is redundant? (I see that it comes from reverting my patch initially, but maybe it should be removed?)

Copy link
Member

Choose a reason for hiding this comment

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

Agree

Copy link
Member

Choose a reason for hiding this comment

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

They will be cleared in the background.

@alesapin
Copy link
Member

Test fixed here #30723

@@ -1470,6 +1468,7 @@ void StorageMergeTree::movePartitionToTable(const StoragePtr & dest_table, const
transaction.commit(&lock);
}

clearOldMutations(true);
Copy link
Member

Choose a reason for hiding this comment

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

They will be cleared in the background.

@tavplubix
Copy link
Member Author

AST fuzzer (MSan) - #30756

@tavplubix tavplubix merged commit ac4a9bc into master Oct 27, 2021
@tavplubix tavplubix deleted the fix_00975_move_partition_merge_tree branch October 27, 2021 15:19
tavplubix added a commit that referenced this pull request Oct 28, 2021
Backport #30717 to 21.10: Fix 00975_move_partition_merge_tree
tavplubix added a commit that referenced this pull request Oct 28, 2021
Backport #30717 to 21.8: Fix 00975_move_partition_merge_tree
tavplubix added a commit that referenced this pull request Oct 28, 2021
Backport #30717 to 21.9: Fix 00975_move_partition_merge_tree
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-bugfix Pull request with bugfix, not backported by default
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Flaky test 00975_move_partition_merge_tree
4 participants