From 8878fec29001cbb3d1a52b2a4055174a1f2e86b6 Mon Sep 17 00:00:00 2001 From: gentle_hu Date: Thu, 10 Nov 2022 10:05:22 +0800 Subject: [PATCH] fix the codegen memory leak --- src/gausskernel/runtime/codegen/gscodegen.cpp | 3 ++- src/gausskernel/runtime/executor/execMain.cpp | 5 +++-- src/include/codegen/gscodegen.h | 8 ++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/gausskernel/runtime/codegen/gscodegen.cpp b/src/gausskernel/runtime/codegen/gscodegen.cpp index ae515cfeb1..d69cbfb6fa 100644 --- a/src/gausskernel/runtime/codegen/gscodegen.cpp +++ b/src/gausskernel/runtime/codegen/gscodegen.cpp @@ -1036,7 +1036,8 @@ void CodeGenThreadInitialize() bool CodeGenThreadObjectReady() { - return t_thrd.codegen_cxt.thr_codegen_obj != NULL && !t_thrd.codegen_cxt.g_runningInFmgr; + return t_thrd.codegen_cxt.thr_codegen_obj != NULL && !t_thrd.codegen_cxt.g_runningInFmgr + && !((dorado::GsCodeGen*)t_thrd.codegen_cxt.thr_codegen_obj)->IsCompiled(); } /** diff --git a/src/gausskernel/runtime/executor/execMain.cpp b/src/gausskernel/runtime/executor/execMain.cpp index 5440a4c3e1..dc311abb8f 100755 --- a/src/gausskernel/runtime/executor/execMain.cpp +++ b/src/gausskernel/runtime/executor/execMain.cpp @@ -787,7 +787,8 @@ void standard_ExecutorEnd(QueryDesc *queryDesc) UnregisterSnapshot(estate->es_crosscheck_snapshot); #ifdef ENABLE_LLVM_COMPILE - if (!t_thrd.codegen_cxt.g_runningInFmgr) { + /* Do not release codegen in Fmgr and Procedure */ + if (!t_thrd.codegen_cxt.g_runningInFmgr && u_sess->SPI_cxt._connected == -1) { CodeGenThreadTearDown(); } #endif @@ -3826,4 +3827,4 @@ TupleTableSlot* FetchPlanSlot(PlanState* subPlanState, ProjectionInfo** projInfo } else { return ExecProcNode(subPlanState); } -} \ No newline at end of file +} diff --git a/src/include/codegen/gscodegen.h b/src/include/codegen/gscodegen.h index d26efb5ace..1684c58579 100644 --- a/src/include/codegen/gscodegen.h +++ b/src/include/codegen/gscodegen.h @@ -539,6 +539,14 @@ public: m_currentModule = NULL; } + /* + * @Description : Get m_moduleCompiled. + */ + inline bool IsCompiled() + { + return m_moduleCompiled; + } + /* * @Description : IR compile to machine code. */ -- Gitee