hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject [04/17] incubator-hawq git commit: HAWQ-1122. Print exception message as warning and abort plan generation.(#920)
Date Fri, 28 Oct 2016 03:53:07 GMT
HAWQ-1122. Print exception message as warning and abort plan generation.(#920)

This is cherry-picked from greenplum-db/gpdb@36b504e65ef2fe68b13c773df9d80a90ddcc9b55


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

Branch: refs/heads/master
Commit: 783d3ea09b7a991496dbd060396960813c031cfc
Parents: f6b7647
Author: Karthikeyan Jambu Rajaraman <karthi.jrk@gmail.com>
Authored: Wed Jul 6 13:53:08 2016 -0700
Committer: rlei <rlei@pivotal.io>
Committed: Fri Oct 28 11:52:20 2016 +0800

----------------------------------------------------------------------
 src/backend/gpopt/CGPOptimizer.cpp    |  6 +++-
 src/backend/gpopt/utils/COptTasks.cpp | 50 ++++++++++++++++++++++++------
 src/include/gpopt/utils/COptTasks.h   |  4 +++
 3 files changed, 50 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/783d3ea0/src/backend/gpopt/CGPOptimizer.cpp
----------------------------------------------------------------------
diff --git a/src/backend/gpopt/CGPOptimizer.cpp b/src/backend/gpopt/CGPOptimizer.cpp
index 4ade344..bcace95 100644
--- a/src/backend/gpopt/CGPOptimizer.cpp
+++ b/src/backend/gpopt/CGPOptimizer.cpp
@@ -77,9 +77,13 @@ CGPOptimizer::PplstmtOptimize
 	}
 	GPOS_CATCH_EX(ex)
 	{
+		if (GPOS_MATCH_EX(ex, gpdxl::ExmaDXL, gpdxl::ExmiWarningAsError))
+		{
+		  elog(ERROR, "PQO unable to generate plan, please see the above message for details.");
+		}
 		if (GPOS_MATCH_EX(ex, gpdxl::ExmaGPDB, gpdxl::ExmiGPDBError))
 		{
-		  elog(ERROR, "GPDB exception. Aborting GPORCA plan generation.");
+		  elog(ERROR, "GPDB exception. Aborting PQO plan generation.");
 		}
 	}
 	GPOS_CATCH_END;

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/783d3ea0/src/backend/gpopt/utils/COptTasks.cpp
----------------------------------------------------------------------
diff --git a/src/backend/gpopt/utils/COptTasks.cpp b/src/backend/gpopt/utils/COptTasks.cpp
index 58085b8..52ef8b5 100644
--- a/src/backend/gpopt/utils/COptTasks.cpp
+++ b/src/backend/gpopt/utils/COptTasks.cpp
@@ -50,6 +50,7 @@
 #include "utils/guc.h"
 
 #include "gpos/base.h"
+#include "gpos/error/CException.h"
 #undef setstate
 
 #include "gpos/_api.h"
@@ -178,6 +179,37 @@ COptTasks::SOptContext::SOptContext()
 	m_szErrorMsg(NULL)
 {}
 
+//---------------------------------------------------------------------------
+//	@function:
+//		COptTasks::SOptContext::HandleError
+//
+//	@doc:
+//		If there is an error print as warning and throw GPOS_EXCEPTION to abort
+//		plan generation. Calling elog::ERROR will result in longjump and hence
+//		a memory leak.
+//---------------------------------------------------------------------------
+void
+COptTasks::SOptContext::HandleError
+	(
+	BOOL *pfUnexpectedFailure
+	)
+{
+	BOOL bhasError = false;
+	if (NULL != m_szErrorMsg)
+	{
+		bhasError = true;
+		elog(WARNING, "%s", m_szErrorMsg);
+	}
+	*pfUnexpectedFailure = m_fUnexpectedFailure;
+
+	// clean up context
+	Free(epinQuery, epinPlStmt);
+	if (bhasError)
+	{
+		GPOS_RAISE(gpdxl::ExmaDXL, gpdxl::ExmiWarningAsError);
+	}
+}
+
 
 //---------------------------------------------------------------------------
 //	@function:
@@ -1611,17 +1643,17 @@ COptTasks::PplstmtOptimize
 	SOptContext octx;
 	octx.m_pquery = pquery;
 	octx.m_fGeneratePlStmt= true;
-	Execute(&PvOptimizeTask, &octx);
-
-	if (NULL != octx.m_szErrorMsg)
+	GPOS_TRY
 	{
-		elog(ERROR, octx.m_szErrorMsg);
+		Execute(&PvOptimizeTask, &octx);
 	}
-	*pfUnexpectedFailure = octx.m_fUnexpectedFailure;
-
-	// clean up context
-	octx.Free(octx.epinQuery, octx.epinPlStmt);
-
+	GPOS_CATCH_EX(ex)
+	{
+		octx.HandleError(pfUnexpectedFailure);
+		GPOS_RETHROW(ex);
+	}
+	GPOS_CATCH_END;
+	octx.HandleError(pfUnexpectedFailure);
 	return octx.m_pplstmt;
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/783d3ea0/src/include/gpopt/utils/COptTasks.h
----------------------------------------------------------------------
diff --git a/src/include/gpopt/utils/COptTasks.h b/src/include/gpopt/utils/COptTasks.h
index 580ab1d..fe24475 100644
--- a/src/include/gpopt/utils/COptTasks.h
+++ b/src/include/gpopt/utils/COptTasks.h
@@ -114,6 +114,10 @@ class COptTasks
 			// ctor
 			SOptContext();
 
+			// If there is an error print as warning and throw exception to abort
+			// plan generation
+			void HandleError(BOOL *pfUnexpectedFailure);
+
 			// free all members except input and output pointers
 			void Free(EPin epinInput, EPin epinOutput);
 


Mime
View raw message