From ad090a92ad9abe3fd50dbd05633ed0a8c60b6d54 Mon Sep 17 00:00:00 2001 From: laishenghao Date: Tue, 24 Sep 2024 14:57:06 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=88=9D=E5=A7=8B=E5=8C=96?= =?UTF-8?q?=E9=98=B6=E6=AE=B5=E5=88=86=E9=85=8D=E5=86=85=E5=AD=98=E5=A4=B1?= =?UTF-8?q?=E8=B4=A5=E5=AF=BC=E8=87=B4=E7=A9=BA=E6=8C=87=E9=92=88core?= =?UTF-8?q?=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/backend/utils/error/elog.cpp | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/common/backend/utils/error/elog.cpp b/src/common/backend/utils/error/elog.cpp index e14e25abe..f1e0be7f4 100644 --- a/src/common/backend/utils/error/elog.cpp +++ b/src/common/backend/utils/error/elog.cpp @@ -326,14 +326,20 @@ bool errstart(int elevel, const char* filename, int lineno, const char* funcname elevel = ERROR; } } - if (u_sess == NULL && (g_instance.role == VUNKNOWN || t_thrd.role == MASTER_THREAD)) { - // there out of memory in startup, we exit directly. - /* Ooops, hard crash time; very little we can do safely here */ - write_stderr("error occurred at %s:%d before error message processing is available\n" - " u_sess is NULL! gaussdb is exit now.\n", - filename ? filename : "(unknown file)", - lineno); - _exit(-1); + + if (unlikely(u_sess == NULL)) { + if (g_instance.role == VUNKNOWN || t_thrd.role == MASTER_THREAD) { + // there out of memory in startup, we exit directly. + /* Ooops, hard crash time; very little we can do safely here */ + write_stderr("error occurred at %s:%d before error message processing is available\n" + " u_sess is NULL! gaussdb is exit now.\n", + filename ? filename : "(unknown file)", lineno); + _exit(STATUS_ERROR); + } else { + write_stderr("error occurred at %s:%d before session context available, u_sess is NULL.\n", + filename ? filename : "(unknown file)", lineno); + ThreadExitCXX(STATUS_ERROR); + } } /* * Now decide whether we need to process this report at all; if it's