fix std::terminate() caused by orca #9
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR fixes a crash,
std::terminate(), caused by an exception occurring in the catch block ofGPOPTOptimizedPlan()duringgpopt_context.CloneErrorMsg().When
CloneErrorMsgfails (typically due to OOM), it throws agpdberror, causingstd::terminate().Postgres has graceful error handling for errors that occur while processing other errors - even during OOM, the
ErrorContexthas reserved space to preserve error messages.So rethrow the error to postgres handler.
Test Plan
Added a new test to the regression
gporca_faulttest.I added a query that errors out during optimization in orca and as the result falls into
catchblock where another exception inCloneErrorMsgis thrown via inject fault.Previously it resulted in the
std::terminate()call & process crashing. Now catch the exception and let the postgres handle it with reserved buffer to preserve error message.Impact
Instead of
server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request.postgres reports an error (in case of OOM we will see it, not std::terminate with exiting processes):