diff --git a/src/gausskernel/optimizer/util/learn/comm.cpp b/src/gausskernel/optimizer/util/learn/comm.cpp index 680299eeb..56c6e0fc1 100644 --- a/src/gausskernel/optimizer/util/learn/comm.cpp +++ b/src/gausskernel/optimizer/util/learn/comm.cpp @@ -409,6 +409,7 @@ bool TryConnectRemoteServer(AiEngineConnInfo* conninfo, char** buf) if (!CheckConnParams(conninfo)) { return false; } + bool exceptionCaught = false; PG_TRY(); { @@ -444,14 +445,19 @@ bool TryConnectRemoteServer(AiEngineConnInfo* conninfo, char** buf) } PG_CATCH(); { + exceptionCaught = true; t_thrd.int_cxt.ImmediateInterruptOK = immediateInterruptOKOld; DestoryAiHandle(connHandle); if (buf != NULL) { *buf = NULL; } - return false; + FlushErrorState(); } PG_END_TRY(); + if (exceptionCaught) { + return false; + } + if (buf != NULL) { *buf = pstrdup(connHandle->rec_buf); }