Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit14d7d61

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 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, weshould do the same here.
1 parentfafeda0 commit14d7d61

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,6 +808,12 @@ pg_wait_sampling_reset_profile(PG_FUNCTION_ARGS)
808808
{
809809
LOCKTAGcollectorTag;
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

813819
pgws_init_lock_tag(&queueTag,PGWS_QUEUE_LOCK);
@@ -819,6 +825,18 @@ pg_wait_sampling_reset_profile(PG_FUNCTION_ARGS)
819825
pgws_collector_hdr->request=PROFILE_RESET;
820826
LockRelease(&collectorTag,ExclusiveLock, false);
821827

828+
/* The collector may have not started yet (it'd be a
829+
* race condition with background worker startup to
830+
* use latch without a check here).
831+
* Or worse, registration of the worker might have been
832+
* denied, if there are too many workers already.
833+
* This is why we cannot wait for its start with a while
834+
* loop.
835+
*/
836+
if (!pgws_collector_hdr->latch)
837+
ereport(ERROR, (errcode(ERRCODE_INTERNAL_ERROR),
838+
errmsg("pg_wait_sampling collector wasn't started")));
839+
822840
SetLatch(pgws_collector_hdr->latch);
823841

824842
LockRelease(&queueTag,ExclusiveLock, false);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp