Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oav8b-0001zg-9O for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Sep 2022 08:31:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oav8a-0001EV-5e for pgsql-hackers@arkaria.postgresql.org; Wed, 21 Sep 2022 08:31:20 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oav8Z-0001EM-Ma for pgsql-hackers@lists.postgresql.org; Wed, 21 Sep 2022 08:31:19 +0000 Received: from forward503p.mail.yandex.net ([2a02:6b8:0:1472:2741:0:8b7:122]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oav8W-0002LO-NS for pgsql-hackers@lists.postgresql.org; Wed, 21 Sep 2022 08:31:19 +0000 Received: from iva5-057a0d1fbbd8.qloud-c.yandex.net (iva5-057a0d1fbbd8.qloud-c.yandex.net [IPv6:2a02:6b8:c0c:7f1c:0:640:57a:d1f]) by forward503p.mail.yandex.net (Yandex) with ESMTP id 697E311022AB; Wed, 21 Sep 2022 11:31:12 +0300 (MSK) Received: by iva5-057a0d1fbbd8.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id MG0tABE20W-V9hGqBwl; Wed, 21 Sep 2022 11:31:11 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) X-Yandex-Fwd: 1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex.ru; s=mail; t=1663749071; bh=ZtAZYE4fwakzk3Be1kd2LvpUiqi5SP/dlJR0wzK9k2g=; h=In-Reply-To:Cc:Date:References:To:Subject:Message-ID:From; b=LCpzH6co9ioGvsuqjVeDAdBaEJGMJrc4NIeJYfyEHGDywYTJMxkw7rvUt2teUhsDV 4v7i/+y+L9YBvKJYqT0jidJklCQOiL15GAZ0Hj3r4YmnuzWGiPXdKMQKP2XWOxf2f/ qtfAYJnWwW8xAZx6ZKIo3+ooMSgHQ2AjvJ9D79cY= Authentication-Results: iva5-057a0d1fbbd8.qloud-c.yandex.net; dkim=pass header.i=@yandex.ru Content-Type: multipart/alternative; boundary="------------oGJ7zO40KdolAmmMH0GIS1od" Message-ID: Date: Wed, 21 Sep 2022 11:30:25 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: RFC: Logging plan of the running query Content-Language: en-US To: torikoshia References: <20220202.170421.204740592565249296.horikyota.ntt@gmail.com> <3bb7bacbc5ef9e58e2ece0557adac98b@oss.nttdata.com> <03c8dcbb-72d2-d3ad-3ad1-9efe69676529@oss.nttdata.com> <20220208.171852.1699766364147189900.horikyota.ntt@gmail.com> <3e94e9b3-83ef-c328-0c5c-f93aa3224790@oss.nttdata.com> <3d121ed5f81cef588bac836b43f5d1f9@oss.nttdata.com> <379d69c0b3d058997550f88e73ffddd6@oss.nttdata.com> <727712bcaa8d449615820c16d15e452e@oss.nttdata.com> <598171663576373@mail.yandex.ru> <38f4e19323b264e5975c60010b512b15@oss.nttdata.com> Cc: pgsql-hackers@lists.postgresql.org From: Alena Rybakina In-Reply-To: <38f4e19323b264e5975c60010b512b15@oss.nttdata.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------oGJ7zO40KdolAmmMH0GIS1od Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit  Ok, I get it. > Since GetLockMethodLocalHash() is only used for assertions, this is > only defined when USE_ASSERT_CHECKING is enabled. This patch uses > GetLockMethodLocalHash() not only for the assertion purpose, so I > removed "ifdef USE_ASSERT_CHECKING" for this function. I belive it > does not lead to skip errors. Agree. > Since these processes are needed for nested queries, not only for > AbortSubTransaction[1], added comments on it. I also noticed it. However I also discovered that above function declarations to be aplied for explain command and used to be printed details of the executed query. We have a similar task to print the plan of an interrupted process making a request for a specific pid. In short, I think, this task is different and for separating these parts I added this comment. > I feel this comment is unnecessary since the explanation of > HandleLogQueryPlanInterrupt() is written in explain.c and no functions > in explain.h have comments in it. Yes, I was worried about it. I understood it, thank for explaining. > > AFAIU both of them are processed since SendProcSignal flags > ps_signalFlags for each signal. > > ``` > SendProcSignal(pid_t pid, ProcSignalReason reason, BackendId backendId) > { > volatile ProcSignalSlot *slot; > ...(snip)... > 278 if (slot->pss_pid == pid) > 279 { > 280 /* Atomically set the proper flag */ > 281 slot->pss_signalFlags[reason] = true; > 282 /* Send signal */ > 283 return kill(pid, SIGUSR1); > ``` > > Comments of ProcSignalReason also say 'We can cope with concurrent > signals for different reasons'. > > ```C > /* > * Reasons for signaling a Postgres child process (a backend or an > auxiliary > * process, like checkpointer). We can cope with concurrent signals for > different > * reasons. However, if the same reason is signaled multiple times in > quick > * succession, the process is likely to observe only one notification > of it. > * This is okay for the present uses. > ... > typedef enum > { > PROCSIG_CATCHUP_INTERRUPT, /* sinval catchup interrupt */ > PROCSIG_NOTIFY_INTERRUPT, /* listen/notify interrupt */ > PROCSIG_PARALLEL_MESSAGE, /* message from cooperating parallel backend */ > PROCSIG_WALSND_INIT_STOPPING, /* ask walsenders to prepare for > shutdown */ > PROCSIG_BARRIER, /* global barrier interrupt */ > PROCSIG_LOG_MEMORY_CONTEXT, /* ask backend to log the memory contexts */ > PROCSIG_LOG_QUERY_PLAN, /* ask backend to log plan of the current > query */ > ... > } ProcSignalReason; > ``` > > > [1] > https://www.postgresql.org/message-id/8b53b32f-26cc-0531-4ac0-27310e0bef4b%40oss.nttdata.com --------------oGJ7zO40KdolAmmMH0GIS1od Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit

 Ok, I get it.

Since GetLockMethodLocalHash() is only used for assertions, this is only defined when USE_ASSERT_CHECKING is enabled. This patch uses GetLockMethodLocalHash() not only for the assertion purpose, so I removed "ifdef USE_ASSERT_CHECKING" for this function. I belive it does not lead to skip errors.
Agree.
Since these processes are needed for nested queries, not only for AbortSubTransaction[1], added comments on it.

I also noticed it. However I also discovered that above function declarations to be aplied for explain command and used to be printed details of the executed query.

We have a similar task to print the plan of an interrupted process making a request for a specific pid.

In short, I think, this task is different and for separating these parts I added this comment.

I feel this comment is unnecessary since the explanation of HandleLogQueryPlanInterrupt() is written in explain.c and no functions in explain.h have comments in it.

Yes, I was worried about it. I understood it, thank for explaining.


AFAIU both of them are processed since SendProcSignal flags ps_signalFlags for each signal.

```
SendProcSignal(pid_t pid, ProcSignalReason reason, BackendId backendId)
{
volatile ProcSignalSlot *slot;
...(snip)...
278 if (slot->pss_pid == pid)
279 {
280 /* Atomically set the proper flag */
281 slot->pss_signalFlags[reason] = true;
282 /* Send signal */
283 return kill(pid, SIGUSR1);
```

Comments of ProcSignalReason also say 'We can cope with concurrent signals for different reasons'.

```C
/*
* Reasons for signaling a Postgres child process (a backend or an auxiliary
* process, like checkpointer). We can cope with concurrent signals for different
* reasons. However, if the same reason is signaled multiple times in quick
* succession, the process is likely to observe only one notification of it.
* This is okay for the present uses.
...
typedef enum
{
PROCSIG_CATCHUP_INTERRUPT, /* sinval catchup interrupt */
PROCSIG_NOTIFY_INTERRUPT, /* listen/notify interrupt */
PROCSIG_PARALLEL_MESSAGE, /* message from cooperating parallel backend */
PROCSIG_WALSND_INIT_STOPPING, /* ask walsenders to prepare for shutdown */
PROCSIG_BARRIER, /* global barrier interrupt */
PROCSIG_LOG_MEMORY_CONTEXT, /* ask backend to log the memory contexts */
PROCSIG_LOG_QUERY_PLAN, /* ask backend to log plan of the current query */
...
} ProcSignalReason;
```


[1] https://www.postgresql.org/message-id/8b53b32f-26cc-0531-4ac0-27310e0bef4b%40oss.nttdata.com
--------------oGJ7zO40KdolAmmMH0GIS1od--