Repository: incubator-hawq Updated Branches: refs/heads/master 8595cdb81 -> 47dd8f6c4
HAWQ-1417. Fixed crash when ANALYZE after COPY because of invalid resource owner Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/47dd8f6c Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/47dd8f6c Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/47dd8f6c Branch: refs/heads/master Commit: 47dd8f6c4eef16e43a77aa2be4360ee8a250015c Parents: 8595cdb Author: Ming LI <[email protected]> Authored: Tue Mar 28 15:52:02 2017 +0800 Committer: Ming LI <[email protected]> Committed: Fri Apr 7 10:00:10 2017 +0800 ---------------------------------------------------------------------- src/backend/commands/analyze.c | 11 +++++++++++ 1 file changed, 11 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/47dd8f6c/src/backend/commands/analyze.c ---------------------------------------------------------------------- diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index 65d9bd3..a4a1f24 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -308,6 +308,7 @@ void analyzeStmt(VacuumStmt *stmt, List *relids, int preferred_seg_num) ListCell *le1 = NULL; int successCount = 0, failCount = 0; StringInfoData failNames; + ResourceOwner owner, oldOwner; /** * Ensure that an ANALYZE is requested. @@ -477,6 +478,13 @@ void analyzeStmt(VacuumStmt *stmt, List *relids, int preferred_seg_num) } /** + * Create a resource owner to keep track of our resources even not in trasaction block + */ + owner = ResourceOwnerCreate(CurrentResourceOwner, "analyzeStmt"); + oldOwner = CurrentResourceOwner; + CurrentResourceOwner = owner; + + /** * we use preferred_seg_num as default and * compute target_seg_num based on data size and distributed type * if there is no preferred_seg_num. @@ -808,6 +816,9 @@ void analyzeStmt(VacuumStmt *stmt, List *relids, int preferred_seg_num) elog(failCount > 0 ? INFO : elevel, "ANALYZE completed. Success: %d, Failure: %d %s", successCount, failCount, failNames.data); pfree(failNames.data); + ResourceOwnerDelete(owner); + CurrentResourceOwner = oldOwner; + Assert(analyzeStatementContext == CurrentMemoryContext); MemoryContextSwitchTo(callerContext); MemoryContextDelete(analyzeStatementContext);
