Cleanup perf_counters on backend exit

This commit is contained in:
Konstantin Knizhnik
2025-07-24 17:12:25 +03:00
parent 3e5bbe7027
commit 3847ab73a7
2 changed files with 15 additions and 3 deletions

View File

@@ -2551,12 +2551,17 @@ communicator_read_slru_segment(SlruKind kind, int64 segno, neon_request_lsns *re
void
communicator_reconfigure_timeout_if_needed(void)
{
bool needs_set = (MyPState->ring_receive != MyPState->ring_unused ||
(MIN_BACKEND_PREFETCH_LSN != InvalidXLogRecPtr &&
MIN_BACKEND_PREFETCH_LSN != GetXLogReplayRecPtr(NULL))) &&
bool needs_set = MyPState->ring_receive != MyPState->ring_unused &&
!AmPrewarmWorker && /* do not pump prefetch state in prewarm worker */
readahead_getpage_pull_timeout_ms > 0;
if (!needs_set && MIN_BACKEND_PREFETCH_LSN != InvalidXLogRecPtr)
{
if (last_replay_lsn == InvalidXLogRecPtr)
MIN_BACKEND_PREFETCH_LSN = InvalidXLogRecPtr;
else
needs_set = true; /* Can not reset MIN_BACKEND_PREFETCH_LSN now, have to do it later */
}
if (needs_set != timeout_set)
{
/*

View File

@@ -13,6 +13,7 @@
#include "funcapi.h"
#include "miscadmin.h"
#include "storage/ipc.h"
#include "storage/proc.h"
#include "storage/shmem.h"
#include "utils/builtins.h"
@@ -42,6 +43,11 @@ NeonPerfCountersShmemRequest(void)
}
static void
NeonPerfCountersReset(int code, Datum arg)
{
memset(MyNeonCounters, 0, sizeof(*MyNeonCounters));
}
void
NeonPerfCountersShmemInit(void)
@@ -58,6 +64,7 @@ NeonPerfCountersShmemInit(void)
{
/* shared memory is initialized to zeros, so nothing to do here */
}
on_shmem_exit(NeonPerfCountersReset, 0);
}
static inline void