Fix stop gaussdb failed when init thread failed.
This commit is contained in:
@ -114,6 +114,7 @@ int main(int argc, char* argv[])
|
||||
PmTopMemoryContext = t_thrd.top_mem_cxt;
|
||||
|
||||
knl_thread_init(MASTER_THREAD);
|
||||
t_thrd.bn = NULL;
|
||||
|
||||
t_thrd.fake_session = create_session_context(t_thrd.top_mem_cxt, 0);
|
||||
t_thrd.fake_session->status = KNL_SESS_FAKE;
|
||||
|
||||
@ -10074,6 +10074,20 @@ int GaussDbThreadMain(knl_thread_arg* arg)
|
||||
/* Do this sooner rather than later... */
|
||||
IsUnderPostmaster = true; /* we are a postmaster subprocess now */
|
||||
Assert(thread_role == arg->role);
|
||||
/*
|
||||
* We should set bn at the beginning of this function, cause if we meet some error before set bn, then we
|
||||
* can't set t_thrd.bn->dead_end to true(check gs_thread_exit), which will lead CleanupBackend failed.
|
||||
* The logic of get child slot refer to PortInitialize -> read_backend_variables -> restore_backend_variables
|
||||
*/
|
||||
int childSlot = 0;
|
||||
if (arg != NULL) {
|
||||
if (arg->role == RPC_WORKER) {
|
||||
childSlot = backend_save_para.MyPMChildSlot;
|
||||
} else {
|
||||
childSlot = ((BackendParameters*)arg->save_para)->MyPMChildSlot;
|
||||
}
|
||||
}
|
||||
t_thrd.bn = GetBackend(childSlot);
|
||||
/* Check this thread will use reserved memory or not */
|
||||
is_memory_backend_reserved(arg);
|
||||
/* Initialize the Memory Protection at the thread level */
|
||||
@ -10130,8 +10144,6 @@ int GaussDbThreadMain(knl_thread_arg* arg)
|
||||
|
||||
PortInitialize(&port, arg);
|
||||
|
||||
t_thrd.bn = GetBackend(t_thrd.proc_cxt.MyPMChildSlot);
|
||||
|
||||
/* We don't need read GUC variables */
|
||||
if (!FencedUDFMasterMode) {
|
||||
/* Read in remaining GUC variables */
|
||||
|
||||
@ -1478,11 +1478,11 @@ void knl_thread_mot_init()
|
||||
|
||||
void knl_thread_init(knl_thread_role role)
|
||||
{
|
||||
/* doesn't init t_thrd.bn, check GaussDbThreadMain for detail */
|
||||
t_thrd.role = role;
|
||||
t_thrd.subrole = NO_SUBROLE;
|
||||
t_thrd.proc = NULL;
|
||||
t_thrd.pgxact = NULL;
|
||||
t_thrd.bn = NULL;
|
||||
t_thrd.myLogicTid = 10000;
|
||||
t_thrd.fake_session = NULL;
|
||||
t_thrd.threadpool_cxt.reaper_dead_session = false;
|
||||
|
||||
Reference in New Issue
Block a user