Repository: incubator-hawq
Updated Branches:
  refs/heads/master b53484511 -> 4ef7022e7


HAWQ-1487. Fix hang process due to deadlock when it try to process interrupt in 
error handling


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/4ef7022e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/4ef7022e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/4ef7022e

Branch: refs/heads/master
Commit: 4ef7022e70e53e19e4bc3d2f768324f292304efb
Parents: b534845
Author: Ruilong Huo <[email protected]>
Authored: Tue Jun 13 18:11:01 2017 +0800
Committer: Ruilong Huo <[email protected]>
Committed: Wed Jun 21 09:45:18 2017 +0800

----------------------------------------------------------------------
 src/backend/utils/error/elog.c | 56 ++++++++++++++++++++++++++++++++++++-
 1 file changed, 55 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/4ef7022e/src/backend/utils/error/elog.c
----------------------------------------------------------------------
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 57ce2ce..a54177b 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -489,7 +489,23 @@ errstart(int elevel, const char *filename, int lineno,
     edata->saved_errno = errno;
 
 #ifndef WIN32
+    bool save_ImmediateInterruptOK = ImmediateInterruptOK;
+    /*
+     * We may be called while ImmediateInterruptOK is true; turn it off
+     * while messing with elog processing.
+     */
+    ImmediateInterruptOK = false;
+
     edata->stacktracesize = backtrace(edata->stacktracearray, 30);
+
+    /*
+     * Restore ImmediateInterruptOK, and check for interrupts if needed.
+     */
+    ImmediateInterruptOK = save_ImmediateInterruptOK;
+    if (save_ImmediateInterruptOK)
+    {
+        CHECK_FOR_INTERRUPTS();
+    }
 #else
     edata->stacktracesize = 0;
 #endif
@@ -4371,7 +4387,23 @@ uint32 gp_backtrace(void **stackAddresses, uint32 
maxStackDepth)
        }
        else
        {
+               bool save_ImmediateInterruptOK = ImmediateInterruptOK;
+               /*
+                * We may be called while ImmediateInterruptOK is true; turn it 
off
+                * while messing with elog processing.
+                */
+               ImmediateInterruptOK = false;
+
                depth  = backtrace(stackAddresses, maxStackDepth);
+
+               /*
+                * Restore ImmediateInterruptOK, and check for interrupts if 
needed.
+                */
+               ImmediateInterruptOK = save_ImmediateInterruptOK;
+               if (save_ImmediateInterruptOK)
+               {
+                       CHECK_FOR_INTERRUPTS();
+               }
        }
 
        Assert(depth > 0);
@@ -4379,7 +4411,29 @@ uint32 gp_backtrace(void **stackAddresses, uint32 
maxStackDepth)
        return depth;
 
 #else
-       return backtrace(stackAddresses, maxStackDepth);
+       bool save_ImmediateInterruptOK = ImmediateInterruptOK;
+       /*
+        * We may be called while ImmediateInterruptOK is true; turn it off
+        * while messing with elog processing.
+        */
+       ImmediateInterruptOK = false;
+
+       uint32 depth = 0;
+
+       depth = backtrace(stackAddresses, maxStackDepth);
+
+       Assert (depth > 0);
+
+       /*
+        * Restore ImmediateInterruptOK, and check for interrupts if needed.
+        */
+       ImmediateInterruptOK = save_ImmediateInterruptOK;
+       if (save_ImmediateInterruptOK)
+       {
+               CHECK_FOR_INTERRUPTS();
+       }
+
+       return depth;
 #endif
 }
 

Reply via email to