!2874 autovacuum launcher线程开始时重置queryMemInChunks相关变量

Merge pull request !2874 from CCA/fixbug
This commit is contained in:
opengauss-bot
2023-03-20 14:08:22 +00:00
committed by Gitee
2 changed files with 18 additions and 10 deletions

View File

@ -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;

View File

@ -395,6 +395,14 @@ NON_EXEC_STATIC void AutoVacLauncherMain()
t_thrd.autovacuum_cxt.AutoVacuumShmem->av_launcherpid = t_thrd.proc_cxt.MyProcPid;
if (likely(t_thrd.shemem_ptr_cxt.mySessionMemoryEntry != NULL)) {
t_thrd.shemem_ptr_cxt.mySessionMemoryEntry->initMemInChunks = t_thrd.utils_cxt.trackedMemChunks;
t_thrd.shemem_ptr_cxt.mySessionMemoryEntry->queryMemInChunks = t_thrd.utils_cxt.trackedMemChunks;
t_thrd.shemem_ptr_cxt.mySessionMemoryEntry->peakChunksQuery = t_thrd.utils_cxt.trackedMemChunks;
}
t_thrd.utils_cxt.peakedBytesInQueryLifeCycle = 0;
t_thrd.utils_cxt.basedBytesInQueryLifeCycle = 0;
/*
* Create the initial database list. The invariant we want this list to
* keep is that it's ordered by decreasing next_time. As soon as an entry