NJrslv opened a new pull request, #1481:
URL: https://github.com/apache/cloudberry/pull/1481

   ### What does this PR do?
   This PR fixes a crash, `std::terminate()`, caused by an exception occurring 
in the catch block of `GPOPTOptimizedPlan()` during 
`gpopt_context.CloneErrorMsg()`.
   
   When `CloneErrorMsg` fails (typically due to OOM), it throws a `gpdb` error, 
causing `std::terminate()`.
   
   Postgres has graceful error handling for errors that occur while processing 
other errors - even during OOM, the `ErrorContext` has reserved space to 
preserve error messages. 
   
   So rethrow the error to postgres handler.
   
   ### Test Plan
   Added a new test to the regression `gporca_fault` test.
    
   I added a query that errors out during optimization in orca and as the 
result falls into `catch` block where another exception in `CloneErrorMsg` is 
thrown. 
   
   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 
   ```sql
   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):
   ```sql
   ERROR:  ...
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to