From 7a5a56852ffc8acf49a59116a0f9cfaeafeca320 Mon Sep 17 00:00:00 2001 From: cca5507 Date: Fri, 3 Mar 2023 17:40:13 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=87=BD=E6=95=B0memTracker?= =?UTF-8?q?=5FReserveMemChunks=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/backend/utils/mmgr/memprot.cpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/common/backend/utils/mmgr/memprot.cpp b/src/common/backend/utils/mmgr/memprot.cpp index 7947c26fc..595b28278 100755 --- a/src/common/backend/utils/mmgr/memprot.cpp +++ b/src/common/backend/utils/mmgr/memprot.cpp @@ -580,16 +580,6 @@ static bool memTracker_ReserveMemChunks(int32 numChunksToReserve, bool needProte Assert(0 < numChunksToReserve); - /* query level memory verification */ - if (t_thrd.shemem_ptr_cxt.mySessionMemoryEntry && type != MEM_SHRD) { - /* 1. increase memory in chunk at query level */ - total = gs_atomic_add_32(&(t_thrd.shemem_ptr_cxt.mySessionMemoryEntry->queryMemInChunks), numChunksToReserve); - - /* 2. update the peak memory of the query */ - if (t_thrd.shemem_ptr_cxt.mySessionMemoryEntry->peakChunksQuery < total) - gs_lock_test_and_set(&(t_thrd.shemem_ptr_cxt.mySessionMemoryEntry->peakChunksQuery), total); - } - /* increase chunk quota at global gaussdb process level */ if (t_thrd.utils_cxt.backend_reserved) { currSize = &backendUsedMemInChunk; @@ -611,6 +601,16 @@ static bool memTracker_ReserveMemChunks(int32 numChunksToReserve, bool needProte t_thrd.utils_cxt.beyondChunk = 0; } + /* query level memory verification */ + if (t_thrd.shemem_ptr_cxt.mySessionMemoryEntry && type != MEM_SHRD) { + /* 1. increase memory in chunk at query level */ + total = gs_atomic_add_32(&(t_thrd.shemem_ptr_cxt.mySessionMemoryEntry->queryMemInChunks), numChunksToReserve); + + /* 2. update the peak memory of the query */ + if (t_thrd.shemem_ptr_cxt.mySessionMemoryEntry->peakChunksQuery < total) + gs_lock_test_and_set(&(t_thrd.shemem_ptr_cxt.mySessionMemoryEntry->peakChunksQuery), total); + } + if (peakChunksPerProcess < processMemInChunks + backendUsedMemInChunk) { peakChunksPerProcess = processMemInChunks + backendUsedMemInChunk;