HAWQ-569. Fixing an assertion failure and a potential double release of 
workfile_queryspace queryEntry


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

Branch: refs/heads/HAWQ-546
Commit: cfcdbf5fae8a44045fcfe5835a4b40ec6e62415e
Parents: 7ba95a8
Author: Foyzur Rahman <foyzur.rah...@gopivotal.com>
Authored: Mon Feb 29 19:09:48 2016 -0800
Committer: Oleksandr Diachenko <odiache...@pivotal.io>
Committed: Wed Mar 30 17:23:29 2016 -0700

----------------------------------------------------------------------
 .../utils/workfile_manager/workfile_queryspace.c     | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/cfcdbf5f/src/backend/utils/workfile_manager/workfile_queryspace.c
----------------------------------------------------------------------
diff --git a/src/backend/utils/workfile_manager/workfile_queryspace.c 
b/src/backend/utils/workfile_manager/workfile_queryspace.c
index a421ceb..7010229 100644
--- a/src/backend/utils/workfile_manager/workfile_queryspace.c
+++ b/src/backend/utils/workfile_manager/workfile_queryspace.c
@@ -302,7 +302,6 @@ WorkfileQueryspace_ReleaseEntry(void)
        }
 
        querySpaceNestingLevel--;
-       Assert(querySpaceNestingLevel >= 0);
 
        if (querySpaceNestingLevel > 0)
        {
@@ -313,15 +312,25 @@ WorkfileQueryspace_ReleaseEntry(void)
                return;
        }
 
+       int session_id = queryEntry->key.session_id;
+       int command_count = queryEntry->key.command_count;
+
        bool deleted = SyncHTRelease(queryspace_Hashtable, queryEntry);
 
+       /*
+        * Set the queryEntry to NULL as we may soon CHECK_FOR_INTERRUPTS, 
which can come back to this
+        * method if an ERROR cleanup (e.g., because of a QueryCancelPending) 
invokes ExecutorEnd.
+        * We don't want to release our queryEntry again.
+        */
+       queryEntry = NULL;
+
        if (deleted)
        {
                elog(gp_workfile_caching_loglevel, "Deleted entry for query 
(sessionid=%d, commandcnt=%d)",
-                               queryEntry->key.session_id, 
queryEntry->key.command_count);
+                               session_id, command_count);
        }
 
-       queryEntry = NULL;
+       Assert(querySpaceNestingLevel >= 0);
 }
 
 /*

Reply via email to