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 forever hanging when HashAgg is called by apply #12760

Merged
merged 4 commits into from
Oct 16, 2019

Conversation

SunRunAway
Copy link
Contributor

@SunRunAway SunRunAway commented Oct 16, 2019

What problem does this PR solve?

Fix #12759

What is changed and how it works?

The parent executors(apply) of HashAgg may call HashAgg.Next once more to make sure the returned size of chunk is 0.
HashAgg.Next handle these calls incorrectly after its all finalWorks exits.

On each call of HashAgg.Next after the job done, it returns a chunk with 0 size, but put a chk into finalInputCh. Each apply executor will call a HashAgg.Next once more, when the number of parent executors exceeds the channel buffer, the query will hang forever.

Explain the example in #12759,

  1. The size of the channel buffer is 4,
  2. The first call of HashAgg.Next which returns a one-row chunk to its parent, sends the chunk into the buffer (This is valid).
  3. Three times calls of HashAgg.Next called by each of the three apply, which returns a zero-row chunk to its parent, sends the chunk into the buffer (This should not happen).
  4. Now the channel is full.
  5. One more call of HashAgg.Next called by the session of tidb, which returns a zero-row chunk to its parent, sends the chunk into the buffer and hangs forever.

Check List

Tests

  • Unit test
  • Integration test

Code changes

  • None

Side effects

  • None

Related changes

  • None

Release note

  • Fix forever hanging when HashAgg is called by apply.

@SunRunAway SunRunAway requested review from XuHuaiyu, qw4990 and zz-jason and removed request for zz-jason, qw4990 and XuHuaiyu October 16, 2019 10:13
@SunRunAway
Copy link
Contributor Author

/run-all-tests

@codecov
Copy link

codecov bot commented Oct 16, 2019

Codecov Report

Merging #12760 into master will not change coverage.
The diff coverage is n/a.

@@             Coverage Diff             @@
##             master     #12760   +/-   ##
===========================================
  Coverage   79.9575%   79.9575%           
===========================================
  Files           462        462           
  Lines        105416     105416           
===========================================
  Hits          84288      84288           
  Misses        14902      14902           
  Partials       6226       6226

Copy link
Contributor

@XuHuaiyu XuHuaiyu left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

LGTM

@SunRunAway SunRunAway merged commit 5564267 into pingcap:master Oct 16, 2019
@SunRunAway SunRunAway deleted the issue12759-hashagg branch October 16, 2019 12:16
@sre-bot
Copy link
Contributor

sre-bot commented Oct 16, 2019

cherry pick to release-3.1 failed

@sre-bot
Copy link
Contributor

sre-bot commented Oct 16, 2019

cherry pick to release-3.0 failed

@sre-bot
Copy link
Contributor

sre-bot commented Oct 16, 2019

cherry pick to release-2.1 failed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/execution SIG execution type/bugfix This PR fixes a bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HashAgg called by apply may hang forever.
4 participants