Skip to content

Introduced MergeTask and MutateTask#25165

Merged
nikitamikhaylov merged 124 commits intoClickHouse:masterfrom
nikitamikhaylov:merge-task-save
Sep 16, 2021
Merged

Introduced MergeTask and MutateTask#25165
nikitamikhaylov merged 124 commits intoClickHouse:masterfrom
nikitamikhaylov:merge-task-save

Conversation

@nikitamikhaylov
Copy link
Copy Markdown
Member

@nikitamikhaylov nikitamikhaylov commented Jun 10, 2021

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Changelog category:

  • New Feature

Changelog entry:
Added an ability to suspend and resume a process of a merge. This is needed for a better scheduling and controlling of merges execution. #22381

@nikitamikhaylov
Copy link
Copy Markdown
Member Author

@Mergifyio update

@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Jun 22, 2021

Command update: success

Branch has been successfully updated

@kitaisreal kitaisreal self-assigned this Jun 29, 2021
@nikitamikhaylov nikitamikhaylov removed the submodule changed At least one submodule changed in this PR. label Jul 5, 2021
@robot-ch-test-poll1 robot-ch-test-poll1 added the submodule changed At least one submodule changed in this PR. label Jul 12, 2021
@robot-ch-test-poll3 robot-ch-test-poll3 removed the submodule changed At least one submodule changed in this PR. label Jul 13, 2021

bool ReplicatedMergeMutateTaskBase::executeImpl()
{
MemoryTrackerThreadSwitcherPtr switcher;
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.

Maybe std::optional

Copy link
Copy Markdown
Member Author

@nikitamikhaylov nikitamikhaylov Sep 13, 2021

Choose a reason for hiding this comment

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

Why? It is RAII class.
Need to add comment, of course

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.

That's ok, we also call dtor for std::optional :)
Just one needless heap allocation ...

* then it will be executed for a long time, because the result of the merge is not really needed immediately.
* It is better to merge small parts as soon as possible.
*/
class MergeTask
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.

Well, we should find some way how to improve this code.
It is mainly only moved code, but now it became a little bit unreadable.
We can kind of leave it that way, but it will be a tech depth. I am ok if we have another one following pr with it.

A couple of ideas what to do:

  • constructor has a lot of params - maybe group them into one or several structs, also add comment to them
  • there are several states and according functions, but prev variables from stack are now all together. maybe we could create separate struct for each stage, which is alive only while stage is being executed
  • also maybe replace enum with stages to an array of member functions + current index - because we execute them in order.

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.

BTW MutateTask looks more readable

@nikitamikhaylov nikitamikhaylov changed the title Introduced MergeTask Introduced MergeTask and MutateTask Sep 16, 2021
@nikitamikhaylov
Copy link
Copy Markdown
Member Author

Some tests become flaky after my changes or this PR contains a bug. Nevertheless I merge it and will fix all issues ASAP. Because I don't want to resolve conflicts every day.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr-feature Pull request with new product feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants