Skip to content

Reset column argument for runningAccumulate#8326

Merged
alexey-milovidov merged 5 commits intoClickHouse:masterfrom
kononencheg:kononencheg/runningAccumulate
Dec 28, 2019
Merged

Reset column argument for runningAccumulate#8326
alexey-milovidov merged 5 commits intoClickHouse:masterfrom
kononencheg:kononencheg/runningAccumulate

Conversation

@kononencheg
Copy link
Copy Markdown
Contributor

@kononencheg kononencheg commented Dec 20, 2019

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

Changelog category (leave one):

  • New Feature

Changelog entry (up to few sentences, required except for Non-significant/Documentation categories):

column_with_groups->compareAt(i, i - 1, *column_with_groups, 1) != 0)
{
agg_func.destroy(place.data());
agg_func.create(place.data());
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.

Need something for exception safety if create will fail.
For example, you can add a bool flag and check it in SCOPE_EXIT above.

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.

There is SCOPE_EXIT with agg_func.destroy callback installed at line 93. And if I understood everything correctly

  1. SCOPE_EXIT uses destructor and it will be destroyed in case of exception too;
  2. agg_func.destroy (as I saw in other places) must be called, whenever creation failure occurred.

Is it really need to handle agg_func.create calling exceptions?

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.

Yes, create may fail due to memory limits. In that case, destroy will be called twice. And it may lead to double free.

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.

Done!

Copy link
Copy Markdown
Member

@alexey-milovidov alexey-milovidov left a comment

Choose a reason for hiding this comment

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

Except this minor issue, the code looks perfect!

@alexey-milovidov
Copy link
Copy Markdown
Member

SELECT runningAccumulate() leads to crash.

@kononencheg
Copy link
Copy Markdown
Contributor Author

I’ll fix it on weekend!

@kononencheg
Copy link
Copy Markdown
Contributor Author

SELECT runningAccumulate() leads to crash.

Now arguments count are tested before invocation.


try
{
agg_func.create(place.data());
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.

No... if create has thrown an exception, the data is not created and calling "destroy" is incorrect.

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 take an example from FunctionArrayReduce.

You mean that if create fails - there's no reason to destroy?

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.

Fixed solution below

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.

I take an example from FunctionArrayReduce.

That's strange. I think it's bug - will validate.

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.

Yes, the code was incorrect, see #8446

Copy link
Copy Markdown
Contributor Author

@kononencheg kononencheg Dec 28, 2019

Choose a reason for hiding this comment

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

That’s all for this PR?

@alexey-milovidov
Copy link
Copy Markdown
Member

Almost. Because all tests have failed and server has crashed :)
I will look.

Copy link
Copy Markdown
Member

@alexey-milovidov alexey-milovidov left a comment

Choose a reason for hiding this comment

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

Will be merged with #8450

alexey-milovidov added a commit that referenced this pull request Dec 28, 2019
@alexey-milovidov alexey-milovidov merged commit d7b030d into ClickHouse:master Dec 28, 2019
@alesapin alesapin added the pr-feature Pull request with new product feature label Jan 20, 2020
@filimonov
Copy link
Copy Markdown
Contributor

filimonov commented Mar 20, 2020

Docs need to be updated.

And probably the same should be done for RunningDifference and neighbor

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.

runningAccumulate function with reset key

4 participants