From d97d0b1a5d46b89b9c21d08924f9ef2d0aea3e86 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=20=EF=BC=88cherry=20picked=20commit?= =?UTF-8?q?=20from=20?= 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 31ee6fdbb..8377fcea5 100644 --- a/src/common/backend/utils/error/elog.cpp +++ b/src/common/backend/utils/error/elog.cpp @@ -321,14 +321,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