Repository: incubator-hawq Updated Branches: refs/heads/master 9d0ea4699 -> 914cbc1ab
HAWQ-1371. Fix QE process hang in shared input scan Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/914cbc1a Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/914cbc1a Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/914cbc1a Branch: refs/heads/master Commit: 914cbc1ab43abd421dfe0e139c23ede03dd40f95 Parents: 61780e9 Author: amyrazz44 <a...@pivotal.io> Authored: Tue Mar 7 16:22:18 2017 +0800 Committer: Ruilong Huo <r...@pivotal.io> Committed: Fri Mar 10 15:59:16 2017 +0800 ---------------------------------------------------------------------- src/backend/executor/nodeShareInputScan.c | 39 ++++++++++++++++++++------ 1 file changed, 30 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/914cbc1a/src/backend/executor/nodeShareInputScan.c ---------------------------------------------------------------------- diff --git a/src/backend/executor/nodeShareInputScan.c b/src/backend/executor/nodeShareInputScan.c index 0f08848..049943b 100644 --- a/src/backend/executor/nodeShareInputScan.c +++ b/src/backend/executor/nodeShareInputScan.c @@ -40,7 +40,6 @@ #include "postgres.h" -#include "access/xact.h" #include "cdb/cdbvars.h" #include "executor/executor.h" #include "executor/nodeShareInputScan.h" @@ -641,10 +640,6 @@ read_retry: goto read_retry; else { - if(fd >= 0) - { - gp_retry_close(fd); - } elog(ERROR, "could not read from fifo: %m"); } Assert(!"Never be here"); @@ -664,10 +659,6 @@ write_retry: goto write_retry; else { - if(fd >= 0) - { - gp_retry_close(fd); - } elog(ERROR, "could not write to fifo: %m"); } @@ -751,6 +742,21 @@ shareinput_reader_waitready(int share_id, PlanGenerator planGen) { CHECK_FOR_INTERRUPTS(); + /* + * Readers won't wait for data writing done notification from writer if transaction is + * aborting. Writer may fail to send data writing done notification to readers in two + * cases: + * + * 1. The transaction is aborted due to interrupts or exceptions, i.e., user cancels + * query, division by zero on some segment + * + * 2. Logic errors in reader which incur its unexpected exit, i.e., segmentation fault + */ + if (IsAbortInProgress()) + { + break; + } + MPP_FD_ZERO(&rset); MPP_FD_SET(pctxt->readyfd, &rset); @@ -888,6 +894,21 @@ writer_wait_for_acks(ShareInput_Lk_Context *pctxt, int share_id, int xslice) { CHECK_FOR_INTERRUPTS(); + /* + * Writer won't wait for ack notification from readers if transaction is + * aborting. Readers may fail to send ack notification to writer in two + * cases: + * + * 1. The transaction is aborted due to interrupts or exceptions, i.e., user cancels + * query, division by zero on some segment + * + * 2. Logic errors in reader which incur its unexpected exit, i.e., segmentation fault + */ + if (IsAbortInProgress()) + { + break; + } + MPP_FD_ZERO(&rset); MPP_FD_SET(pctxt->donefd, &rset);