From fd622276e19520ce55e5eef73c2045fb4cc76dd8 Mon Sep 17 00:00:00 2001 From: laishenghao <6529967+dodders@user.noreply.gitee.com> Date: Tue, 4 Mar 2025 02:10:09 +0000 Subject: [PATCH] =?UTF-8?q?=E5=9B=9E=E9=80=80=20'Pull=20Request=20!3620=20?= =?UTF-8?q?:=20=E3=80=90bugfixed=E3=80=91=E8=A7=A3=E5=86=B3=E5=B9=B6?= =?UTF-8?q?=E8=A1=8C=E5=88=9B=E5=BB=BA=E7=B4=A2=E5=BC=95=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E8=AD=A6=E5=91=8A=E6=97=A5=E5=BF=97=E7=9A=84=E9=97=AE=E9=A2=98?= =?UTF-8?q?'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../process/postmaster/bgworker.cpp | 35 ------------------- 1 file changed, 35 deletions(-) diff --git a/src/gausskernel/process/postmaster/bgworker.cpp b/src/gausskernel/process/postmaster/bgworker.cpp index e9a3dc9172..bcb5522d07 100644 --- a/src/gausskernel/process/postmaster/bgworker.cpp +++ b/src/gausskernel/process/postmaster/bgworker.cpp @@ -364,7 +364,6 @@ bool RegisterBackgroundWorker(BgWorkerContext *bwc) BGW_HDR* bgworker_base = (BGW_HDR *)g_instance.bgw_base; BackgroundWorker *bgw = NULL; BackgroundWorkerArgs *bwa = NULL; - Backend* bn = nullptr; /* Construct bgworker thread args */ bwa = (BackgroundWorkerArgs*)MemoryContextAllocZero( @@ -388,49 +387,15 @@ bool RegisterBackgroundWorker(BgWorkerContext *bwc) bwa->bgworker = bgw; bwa->bgworkerId = bgw->bgw_id; - int slot = AssignPostmasterChildSlot(); - if (slot == -1) { - pfree_ext(bwa); - BgworkerPutBackToFreeList(bgw); - return false; - } - - bn = AssignFreeBackEnd(slot); - int thisChildSlot = t_thrd.proc_cxt.MyPMChildSlot; - if (bn) { - GenerateCancelKey(false); - bn->cancel_key = t_thrd.proc_cxt.MyCancelKey; - bn->child_slot = t_thrd.proc_cxt.MyPMChildSlot = slot; - bn->role = BGWORKER; - } else { - ReleasePostmasterChildSlot(slot); - pfree_ext(bwa); - BgworkerPutBackToFreeList(bgw); - ereport(LOG, (errcode(ERRCODE_LOG), errmsg("assign backend failed in RegisterBackgroundWorker"))); - return false; - } - /* Fork a new worker thread */ bgw->bgw_notify_pid = initialize_util_thread(BGWORKER, bwa); - t_thrd.proc_cxt.MyPMChildSlot = thisChildSlot; - /* failed to fork a new thread */ if (bgw->bgw_notify_pid == 0) { pfree_ext(bwa); BgworkerPutBackToFreeList(bgw); - ReleasePostmasterChildSlot(slot); - - bn->pid = 0; - bn->role = (knl_thread_role)0; - bn = nullptr; return false; } - bn->pid = bgw->bgw_notify_pid; - bn->is_autovacuum = false; - DLInitElem(&bn->elem, bn); - DLAddHead(g_instance.backend_list, &bn->elem); - if (g_threadPoolControler) { // Try to bind thread to available CPUs in threadpool g_threadPoolControler->BindThreadToAllAvailCpu(bgw->bgw_notify_pid); -- Gitee