From 930a67a235f5c2e5e4e9868c22f9bb8289cba45e Mon Sep 17 00:00:00 2001 From: Valeriy Zainullin Date: Thu, 19 Jun 2025 18:16:01 +0300 Subject: [PATCH] Check collector has started in pg_wait_sampling_reset_profile. The worker might have not started yet or it may never start, because its registration was cancelled due to worker limit. This commit adds a check for NULL value of pgws_collector_hdr->latch. The previous usage in pg_wait_sampling.c has such a check, we should do the same here. --- pg_wait_sampling.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pg_wait_sampling.c b/pg_wait_sampling.c index f5bd6e0..e165a6a 100644 --- a/pg_wait_sampling.c +++ b/pg_wait_sampling.c @@ -649,6 +649,10 @@ receive_array(SHMRequest request, Size item_size, Size *count) pgws_collector_hdr->request = request; LockRelease(&collectorTag, ExclusiveLock, false); + /* + * Check that the collector was started to avoid NULL + * pointer dereference. + */ if (!pgws_collector_hdr->latch) ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), errmsg("pg_wait_sampling collector wasn't started"))); @@ -819,6 +823,14 @@ pg_wait_sampling_reset_profile(PG_FUNCTION_ARGS) pgws_collector_hdr->request = PROFILE_RESET; LockRelease(&collectorTag, ExclusiveLock, false); + /* + * Check that the collector was started to avoid NULL + * pointer dereference. + */ + if (!pgws_collector_hdr->latch) + ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR), + errmsg("pg_wait_sampling collector wasn't started"))); + SetLatch(pgws_collector_hdr->latch); LockRelease(&queueTag, ExclusiveLock, false); pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy