Skip to content

Commit 392b87c

Browse files
author
Valeriy Zainullin
committed
Check collector has started in pg_wait_sampling_reset_profile.
The worker might have not started yet or it may never start, because it's 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.
1 parent fafeda0 commit 392b87c

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

pg_wait_sampling.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -808,8 +808,26 @@ pg_wait_sampling_reset_profile(PG_FUNCTION_ARGS)
808808
{
809809
LOCKTAG collectorTag;
810810

811+
/*
812+
* This also guards against the case when the
813+
* extension was not loaded at all, but this
814+
* function was called. pgws_collector_hdr is
815+
* NULL in this case.
816+
*/
811817
check_shmem();
812818

819+
/* The collector may have not started yet (it'd be a
820+
* race condition with background worker startup to
821+
* use latch without a check here).
822+
* Or worse, registration of the worker might have been
823+
* denied, if there are too many workers already.
824+
* This is why we cannot wait for its start with a while
825+
* loop.
826+
*/
827+
if (!pgws_collector_hdr->latch)
828+
ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR),
829+
errmsg("pg_wait_sampling collector wasn't started")));
830+
813831
pgws_init_lock_tag(&queueTag, PGWS_QUEUE_LOCK);
814832

815833
LockAcquire(&queueTag, ExclusiveLock, false, false);

0 commit comments

Comments
 (0)
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