diff --git a/src/common/backend/utils/error/elog.cpp b/src/common/backend/utils/error/elog.cpp index 4c490dc88110e42cdc58010118d7d7544f76beef..ce384cc17b428d5f20ce6507136eb2eda9eb6e20 100644 --- a/src/common/backend/utils/error/elog.cpp +++ b/src/common/backend/utils/error/elog.cpp @@ -252,7 +252,7 @@ bool errstart(int elevel, const char* filename, int lineno, const char* funcname * Check some cases in which we want to promote an error into a more * severe error. None of this logic applies for non-error messages. */ - if (elevel >= ERROR) { + if (elevel >= ERROR && u_sess != NULL) { /* * If we are inside a critical section, all errors become PANIC * errors. See miscadmin.h. @@ -316,7 +316,15 @@ 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); + } /* * Now decide whether we need to process this report at all; if it's * warning or less and not enabled for logging, just return FALSE without