Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1j6vek-0003f1-DX for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Feb 2020 12:19:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j6vei-0000Ig-Qk for pgsql-hackers@arkaria.postgresql.org; Wed, 26 Feb 2020 12:19:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1j6vei-0000IZ-IG for pgsql-hackers@lists.postgresql.org; Wed, 26 Feb 2020 12:19:12 +0000 Received: from oss.nttdata.com ([49.212.34.109]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1j6vee-0007t2-Ow for pgsql-hackers@postgresql.org; Wed, 26 Feb 2020 12:19:12 +0000 Received: from hnk.local (sp49-97-94-11.msc.spmode.ne.jp [49.97.94.11]) by oss.nttdata.com (Postfix) with ESMTPSA id BF34C60252; Wed, 26 Feb 2020 21:19:02 +0900 (JST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.101.5 at oss.nttdata.com Subject: Re: Wait event that should be reported while waiting for WAL archiving to finish To: Michael Paquier Cc: Robert Haas , "pgsql-hackers@postgresql.org" References: <20200213032804.GB1520@paquier.xyz> <949931aa-4ed4-d867-a7b5-de9c02b2292b@oss.nttdata.com> <20200213073035.GI1520@paquier.xyz> <61477660-dded-2550-b101-c76a2f864806@oss.nttdata.com> <20200217094857.GB115140@paquier.xyz> <20200218033949.GD4176@paquier.xyz> From: Fujii Masao Message-ID: <164cddb8-d331-753c-6a97-b181206d72d6@oss.nttdata.com> Date: Wed, 26 Feb 2020 21:19:02 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200218033949.GD4176@paquier.xyz> Content-Type: multipart/mixed; boundary="------------FE0A8269780F92B98EDA986C" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------FE0A8269780F92B98EDA986C Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit On 2020/02/18 12:39, Michael Paquier wrote: > On Mon, Feb 17, 2020 at 10:21:23PM +0900, Fujii Masao wrote: >> On 2020/02/17 18:48, Michael Paquier wrote: >>> Actually, I have some questions: >>> 1) Should a new wait event be added in recoveryPausesHere()? That >>> would be IMO useful. >> >> Yes, it's useful, I think. But it's better to implement that >> as a separate patch. > > No problem for me. On second thought, it's OK to add that event into the patch. Attached is the updated version of the patch. This patch adds two wait events for WAL archiving and recovery pause. >>> 2) Perhaps those two points should be replaced with WaitLatch(), where >>> we would use the new wait events introduced? >> >> For what? Maybe it should, but I'm not sure it's worth the trouble. > > I don't have more to offer than signal handling consistency for both > without relying on pg_usleep()'s behavior depending on the platform, > and power consumption. For the recovery pause, the second argument > may not be worth carrying, but we never had this argument for the > archiving wait, did we? I have no idea about this. But I wonder how much that change is helpful to reduce the power consumption because waiting for WAL archive during the backup basically not so frequently happens. Regards, -- Fujii Masao NTT DATA CORPORATION Advanced Platform Technology Group Research and Development Headquarters --------------FE0A8269780F92B98EDA986C Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="wait_event_wal_archive_v4.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="wait_event_wal_archive_v4.patch" diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml index 87586a7b06..6c0c93ffdc 100644 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@ -1335,7 +1335,11 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser Waiting in an extension. - IPC + IPC + BackupWaitWalArchive + Waiting for WAL files required for the backup to be successfully archived. + + BgWorkerShutdown Waiting for background worker to shut down. @@ -1467,6 +1471,10 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser Promote Waiting for standby promotion. + + RecoveryPause + Waiting for recovery to be resumed. + ReplicationOriginDrop Waiting for a replication origin to become inactive to be dropped. diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index d19408b3be..5569606183 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -5945,7 +5945,9 @@ recoveryPausesHere(void) while (RecoveryIsPaused()) { + pgstat_report_wait_start(WAIT_EVENT_RECOVERY_PAUSE); pg_usleep(1000000L); /* 1000 ms */ + pgstat_report_wait_end(); HandleStartupProcInterrupts(); } } @@ -11129,7 +11131,9 @@ do_pg_stop_backup(char *labelfile, bool waitforarchive, TimeLineID *stoptli_p) reported_waiting = true; } + pgstat_report_wait_start(WAIT_EVENT_BACKUP_WAIT_WAL_ARCHIVE); pg_usleep(1000000L); + pgstat_report_wait_end(); if (++waits >= seconds_before_warning) { diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index 462b4d7e06..2400bf31ee 100644 --- a/src/backend/postmaster/pgstat.c +++ b/src/backend/postmaster/pgstat.c @@ -3740,6 +3740,9 @@ pgstat_get_wait_ipc(WaitEventIPC w) switch (w) { + case WAIT_EVENT_BACKUP_WAIT_WAL_ARCHIVE: + event_name = "BackupWaitWalArchive"; + break; case WAIT_EVENT_BGWORKER_SHUTDOWN: event_name = "BgWorkerShutdown"; break; @@ -3839,6 +3842,9 @@ pgstat_get_wait_ipc(WaitEventIPC w) case WAIT_EVENT_PROMOTE: event_name = "Promote"; break; + case WAIT_EVENT_RECOVERY_PAUSE: + event_name = "RecoveryPause"; + break; case WAIT_EVENT_REPLICATION_ORIGIN_DROP: event_name = "ReplicationOriginDrop"; break; diff --git a/src/include/pgstat.h b/src/include/pgstat.h index 3a65a51696..6d8332163c 100644 --- a/src/include/pgstat.h +++ b/src/include/pgstat.h @@ -817,7 +817,8 @@ typedef enum */ typedef enum { - WAIT_EVENT_BGWORKER_SHUTDOWN = PG_WAIT_IPC, + WAIT_EVENT_BACKUP_WAIT_WAL_ARCHIVE = PG_WAIT_IPC, + WAIT_EVENT_BGWORKER_SHUTDOWN, WAIT_EVENT_BGWORKER_STARTUP, WAIT_EVENT_BTREE_PAGE, WAIT_EVENT_CLOG_GROUP_UPDATE, @@ -850,6 +851,7 @@ typedef enum WAIT_EVENT_PARALLEL_FINISH, WAIT_EVENT_PROCARRAY_GROUP_UPDATE, WAIT_EVENT_PROMOTE, + WAIT_EVENT_RECOVERY_PAUSE, WAIT_EVENT_REPLICATION_ORIGIN_DROP, WAIT_EVENT_REPLICATION_SLOT_DROP, WAIT_EVENT_SAFE_SNAPSHOT, --------------FE0A8269780F92B98EDA986C--