You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@impala.apache.org by "Joe McDonnell (Code Review)" <ge...@cloudera.org> on 2020/06/16 19:13:32 UTC

[Impala-ASF-CR] IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink

Joe McDonnell has uploaded this change for review. ( http://gerrit.cloudera.org:8080/16088


Change subject: IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink
......................................................................

IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink

In BufferedPlanRootSink::FlushFinal(), if Cancel() runs
before FlushFinal() waits on the consumer_eos_ condition variable,
the thread in FlushFinal() will wait forever. This is because it
not checking for cancellation or synchronizing with the Cancel()
thread.

Specifically:
Thread A: Calls BufferedPlanRootSink::Cancel(), signalling any
  thread currently waiting on the consumer_eos_ condition variable.
Thread B: Enters FlushFinal(). Never tests RuntimeState::is_cancelled()
  and calls Wait() on the consumer_eos_ condition variable. This waits
  forever.

This changes BufferedPlanRootSink::Cancel() to get the lock_ before
signalling the consumer_eos_ condition variable. It also changes
FlushFinal() to check for is_cancelled() before waiting on the
consumer_eos_ condition variable. There are two cases:
1. FlushFinal() gets the lock_ first and only releases it when waiting
on the consumer_eos_ condition variable. It will get signalled by
Cancel().
2. Cancel() gets the lock_ first and FlushFinal() will not wait,
because is_cancelled() is true.

Testing:
 - Run core tests

Change-Id: Id6f3fbc05420ca95313fa79ea106547feb92b16b
---
M be/src/exec/buffered-plan-root-sink.cc
1 file changed, 11 insertions(+), 2 deletions(-)



  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/88/16088/1
-- 
To view, visit http://gerrit.cloudera.org:8080/16088
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id6f3fbc05420ca95313fa79ea106547feb92b16b
Gerrit-Change-Number: 16088
Gerrit-PatchSet: 1
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>

[Impala-ASF-CR] IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink

Posted by "Tim Armstrong (Code Review)" <ge...@cloudera.org>.
Tim Armstrong has posted comments on this change. ( http://gerrit.cloudera.org:8080/16088 )

Change subject: IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink
......................................................................


Patch Set 1:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/16088/1/be/src/exec/buffered-plan-root-sink.cc
File be/src/exec/buffered-plan-root-sink.cc:

http://gerrit.cloudera.org:8080/#/c/16088/1/be/src/exec/buffered-plan-root-sink.cc@110
PS1, Line 110:   if (!state->is_cancelled()) {
This is still kinda weird - usually the pattern should be waiting in a loop for some predicate to be true. This could still be vulnerable to spurious wakeups, I think.

That wouldn't cause the problem this is fixing, but should probably make this more obviously correct while we're here.



-- 
To view, visit http://gerrit.cloudera.org:8080/16088
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id6f3fbc05420ca95313fa79ea106547feb92b16b
Gerrit-Change-Number: 16088
Gerrit-PatchSet: 1
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Tue, 16 Jun 2020 22:26:06 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink

Posted by "Tim Armstrong (Code Review)" <ge...@cloudera.org>.
Tim Armstrong has posted comments on this change. ( http://gerrit.cloudera.org:8080/16088 )

Change subject: IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink
......................................................................


Patch Set 2: Code-Review+2


-- 
To view, visit http://gerrit.cloudera.org:8080/16088
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id6f3fbc05420ca95313fa79ea106547feb92b16b
Gerrit-Change-Number: 16088
Gerrit-PatchSet: 2
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Tue, 16 Jun 2020 23:47:01 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink

Posted by "Joe McDonnell (Code Review)" <ge...@cloudera.org>.
Joe McDonnell has posted comments on this change. ( http://gerrit.cloudera.org:8080/16088 )

Change subject: IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink
......................................................................


Patch Set 1:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/16088/1//COMMIT_MSG
Commit Message:

http://gerrit.cloudera.org:8080/#/c/16088/1//COMMIT_MSG@11
PS1, Line 11: it
Should be "it is". Will fix.



-- 
To view, visit http://gerrit.cloudera.org:8080/16088
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id6f3fbc05420ca95313fa79ea106547feb92b16b
Gerrit-Change-Number: 16088
Gerrit-PatchSet: 1
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Comment-Date: Tue, 16 Jun 2020 19:53:24 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/16088 )

Change subject: IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink
......................................................................


Patch Set 2: Verified+1


-- 
To view, visit http://gerrit.cloudera.org:8080/16088
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id6f3fbc05420ca95313fa79ea106547feb92b16b
Gerrit-Change-Number: 16088
Gerrit-PatchSet: 2
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Wed, 17 Jun 2020 04:50:08 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/16088 )

Change subject: IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink
......................................................................


Patch Set 1:

Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/6011/ DRY_RUN=true


-- 
To view, visit http://gerrit.cloudera.org:8080/16088
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id6f3fbc05420ca95313fa79ea106547feb92b16b
Gerrit-Change-Number: 16088
Gerrit-PatchSet: 1
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Comment-Date: Tue, 16 Jun 2020 19:19:18 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink

Posted by "Joe McDonnell (Code Review)" <ge...@cloudera.org>.
Joe McDonnell has submitted this change and it was merged. ( http://gerrit.cloudera.org:8080/16088 )

Change subject: IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink
......................................................................

IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink

In BufferedPlanRootSink::FlushFinal(), if Cancel() runs
before FlushFinal() waits on the consumer_eos_ condition variable,
the thread in FlushFinal() will wait forever. This is because it is
not checking for cancellation or synchronizing with the Cancel()
thread.

Specifically:
Thread A: Calls BufferedPlanRootSink::Cancel(), signalling any
  thread currently waiting on the consumer_eos_ condition variable.
Thread B: Enters FlushFinal(). Never tests RuntimeState::is_cancelled()
  and calls Wait() on the consumer_eos_ condition variable. This waits
  forever.

This changes BufferedPlanRootSink::Cancel() to get the lock_ before
signalling the consumer_eos_ condition variable. It also changes
FlushFinal() to call Wait() in a loop. It breaks out of the loop if
it is cancelled or the batch_queue_ is empty. There are two cases:
1. FlushFinal() gets the lock_ first and only releases it when waiting
on the consumer_eos_ condition variable. It will get signalled by
Cancel().
2. Cancel() gets the lock_ first and FlushFinal() will not wait,
because is_cancelled() is true.

Testing:
 - Run core tests

Change-Id: Id6f3fbc05420ca95313fa79ea106547feb92b16b
Reviewed-on: http://gerrit.cloudera.org:8080/16088
Reviewed-by: Tim Armstrong <ta...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>
---
M be/src/exec/buffered-plan-root-sink.cc
1 file changed, 11 insertions(+), 2 deletions(-)

Approvals:
  Tim Armstrong: Looks good to me, approved
  Impala Public Jenkins: Verified

-- 
To view, visit http://gerrit.cloudera.org:8080/16088
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Id6f3fbc05420ca95313fa79ea106547feb92b16b
Gerrit-Change-Number: 16088
Gerrit-PatchSet: 3
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>

[Impala-ASF-CR] IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink

Posted by "Joe McDonnell (Code Review)" <ge...@cloudera.org>.
Joe McDonnell has posted comments on this change. ( http://gerrit.cloudera.org:8080/16088 )

Change subject: IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink
......................................................................


Patch Set 1:

(1 comment)

http://gerrit.cloudera.org:8080/#/c/16088/1/be/src/exec/buffered-plan-root-sink.cc
File be/src/exec/buffered-plan-root-sink.cc:

http://gerrit.cloudera.org:8080/#/c/16088/1/be/src/exec/buffered-plan-root-sink.cc@110
PS1, Line 110:   if (!state->is_cancelled()) {
> This is still kinda weird - usually the pattern should be waiting in a loop
Good point, better to have defensive code. Changed this to a loop that checks whether the queue is empty or this is cancelled. This is a deconstructed version of the IsGetNextEos().



-- 
To view, visit http://gerrit.cloudera.org:8080/16088
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id6f3fbc05420ca95313fa79ea106547feb92b16b
Gerrit-Change-Number: 16088
Gerrit-PatchSet: 1
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Tue, 16 Jun 2020 23:20:31 +0000
Gerrit-HasComments: Yes

[Impala-ASF-CR] IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/16088 )

Change subject: IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink
......................................................................


Patch Set 2:

Build started: https://jenkins.impala.io/job/gerrit-verify-dryrun/6013/ DRY_RUN=true


-- 
To view, visit http://gerrit.cloudera.org:8080/16088
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id6f3fbc05420ca95313fa79ea106547feb92b16b
Gerrit-Change-Number: 16088
Gerrit-PatchSet: 2
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Tue, 16 Jun 2020 23:58:46 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink

Posted by "Joe McDonnell (Code Review)" <ge...@cloudera.org>.
Hello Tim Armstrong, Impala Public Jenkins, 

I'd like you to reexamine a change. Please visit

    http://gerrit.cloudera.org:8080/16088

to look at the new patch set (#2).

Change subject: IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink
......................................................................

IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink

In BufferedPlanRootSink::FlushFinal(), if Cancel() runs
before FlushFinal() waits on the consumer_eos_ condition variable,
the thread in FlushFinal() will wait forever. This is because it is
not checking for cancellation or synchronizing with the Cancel()
thread.

Specifically:
Thread A: Calls BufferedPlanRootSink::Cancel(), signalling any
  thread currently waiting on the consumer_eos_ condition variable.
Thread B: Enters FlushFinal(). Never tests RuntimeState::is_cancelled()
  and calls Wait() on the consumer_eos_ condition variable. This waits
  forever.

This changes BufferedPlanRootSink::Cancel() to get the lock_ before
signalling the consumer_eos_ condition variable. It also changes
FlushFinal() to call Wait() in a loop. It breaks out of the loop if
it is cancelled or the batch_queue_ is empty. There are two cases:
1. FlushFinal() gets the lock_ first and only releases it when waiting
on the consumer_eos_ condition variable. It will get signalled by
Cancel().
2. Cancel() gets the lock_ first and FlushFinal() will not wait,
because is_cancelled() is true.

Testing:
 - Run core tests

Change-Id: Id6f3fbc05420ca95313fa79ea106547feb92b16b
---
M be/src/exec/buffered-plan-root-sink.cc
1 file changed, 11 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.cloudera.org:29418/Impala-ASF refs/changes/88/16088/2
-- 
To view, visit http://gerrit.cloudera.org:8080/16088
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: newpatchset
Gerrit-Change-Id: Id6f3fbc05420ca95313fa79ea106547feb92b16b
Gerrit-Change-Number: 16088
Gerrit-PatchSet: 2
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>

[Impala-ASF-CR] IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/16088 )

Change subject: IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink
......................................................................


Patch Set 1:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/6341/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/16088
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id6f3fbc05420ca95313fa79ea106547feb92b16b
Gerrit-Change-Number: 16088
Gerrit-PatchSet: 1
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Comment-Date: Tue, 16 Jun 2020 19:42:03 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/16088 )

Change subject: IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink
......................................................................


Patch Set 1: Verified+1


-- 
To view, visit http://gerrit.cloudera.org:8080/16088
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id6f3fbc05420ca95313fa79ea106547feb92b16b
Gerrit-Change-Number: 16088
Gerrit-PatchSet: 1
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Tue, 16 Jun 2020 23:57:16 +0000
Gerrit-HasComments: No

[Impala-ASF-CR] IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink

Posted by "Impala Public Jenkins (Code Review)" <ge...@cloudera.org>.
Impala Public Jenkins has posted comments on this change. ( http://gerrit.cloudera.org:8080/16088 )

Change subject: IMPALA-9842: Fix hang when cancelling BufferedPlanRootSink
......................................................................


Patch Set 2:

Build Successful 

https://jenkins.impala.io/job/gerrit-code-review-checks/6343/ : Initial code review checks passed. Use gerrit-verify-dryrun-external or gerrit-verify-dryrun to run full precommit tests.


-- 
To view, visit http://gerrit.cloudera.org:8080/16088
To unsubscribe, visit http://gerrit.cloudera.org:8080/settings

Gerrit-Project: Impala-ASF
Gerrit-Branch: master
Gerrit-MessageType: comment
Gerrit-Change-Id: Id6f3fbc05420ca95313fa79ea106547feb92b16b
Gerrit-Change-Number: 16088
Gerrit-PatchSet: 2
Gerrit-Owner: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Impala Public Jenkins <im...@cloudera.com>
Gerrit-Reviewer: Joe McDonnell <jo...@cloudera.com>
Gerrit-Reviewer: Tim Armstrong <ta...@cloudera.com>
Gerrit-Comment-Date: Tue, 16 Jun 2020 23:49:33 +0000
Gerrit-HasComments: No