Content-Length: 283575 | pFad | http://github.com/postgrespro/pg_wait_sampling/commit/392b87c84bb0c29b2707aa81c68583c6835837f7

2F Check collector has started in pg_wait_sampling_reset_profile. · postgrespro/pg_wait_sampling@392b87c · GitHub
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)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/pg_wait_sampling/commit/392b87c84bb0c29b2707aa81c68583c6835837f7

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy