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.89) (envelope-from ) id 1j286Z-0005So-RJ for pgsql-hackers@arkaria.postgresql.org; Thu, 13 Feb 2020 06:36:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1j286X-0005wG-K7 for pgsql-hackers@arkaria.postgresql.org; Thu, 13 Feb 2020 06:36:05 +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 1j286X-0005vU-B1 for pgsql-hackers@lists.postgresql.org; Thu, 13 Feb 2020 06:36:05 +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 1j286O-0001CI-Jg for pgsql-hackers@postgresql.org; Thu, 13 Feb 2020 06:36:03 +0000 Received: from hnk.local (sp49-97-94-18.msc.spmode.ne.jp [49.97.94.18]) by oss.nttdata.com (Postfix) with ESMTPSA id 16C7A6050F; Thu, 13 Feb 2020 15:35:51 +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: pgsql-hackers@postgresql.org References: <20200213032804.GB1520@paquier.xyz> From: Fujii Masao Message-ID: <949931aa-4ed4-d867-a7b5-de9c02b2292b@oss.nttdata.com> Date: Thu, 13 Feb 2020 15:35:50 +0900 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:68.0) Gecko/20100101 Thunderbird/68.4.2 MIME-Version: 1.0 In-Reply-To: <20200213032804.GB1520@paquier.xyz> Content-Type: multipart/mixed; boundary="------------41888754B6F946B7A27666BE" 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. --------------41888754B6F946B7A27666BE Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit On 2020/02/13 12:28, Michael Paquier wrote: > On Thu, Feb 13, 2020 at 02:29:20AM +0900, Fujii Masao wrote: >> When I saw pg_stat_activity.wait_event while pg_basebackup -X none >> is waiting for WAL archiving to finish, it was either NULL or >> CheckpointDone. I think this is confusing. What about introducing >> new wait_event like WAIT_EVENT_BACKUP_WAIT_WAL_ARCHIVE >> (BackupWaitWalArchive) and reporting it during that period? > > Sounds like a good idea to me. You need to be careful that this does > not overwrite more low-level wait event registration though, so that > could be more tricky than it looks at first sight. Thanks for the advise! Patch attached. I found that the wait events "LogicalRewriteTruncate" and "GSSOpenServer" are not documented. I'm thinking to add them into doc separately if ok. Regards, -- Fujii Masao NTT DATA CORPORATION Advanced Platform Technology Group Research and Development Headquarters --------------41888754B6F946B7A27666BE Content-Type: text/plain; charset=UTF-8; x-mac-type="0"; x-mac-creator="0"; name="wait_event_wal_archive_v1.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="wait_event_wal_archive_v1.patch" diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml index 9129f79bbf..1e2f81d994 100644 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@ -1479,6 +1479,10 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser SyncRep Waiting for confirmation from remote server during synchronous replication. + + BackupWaitWalArchive + Waiting for WAL files required for the backup to be successfully archived. + Timeout BaseBackupThrottle diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 3813eadfb4..d79417b443 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -11095,6 +11095,7 @@ do_pg_stop_backup(char *labelfile, bool waitforarchive, TimeLineID *stoptli_p) seconds_before_warning = 60; waits = 0; + pgstat_report_wait_start(WAIT_EVENT_BACKUP_WAIT_WAL_ARCHIVE); while (XLogArchiveIsBusy(lastxlogfilename) || XLogArchiveIsBusy(histfilename)) { @@ -11120,6 +11121,7 @@ do_pg_stop_backup(char *labelfile, bool waitforarchive, TimeLineID *stoptli_p) "but the database backup will not be usable without all the WAL segments."))); } } + pgstat_report_wait_end(); ereport(NOTICE, (errmsg("all required WAL segments have been archived"))); diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index 7169509a79..6114ab44ee 100644 --- a/src/backend/postmaster/pgstat.c +++ b/src/backend/postmaster/pgstat.c @@ -3848,6 +3848,9 @@ pgstat_get_wait_ipc(WaitEventIPC w) case WAIT_EVENT_SYNC_REP: event_name = "SyncRep"; break; + case WAIT_EVENT_BACKUP_WAIT_WAL_ARCHIVE: + event_name = "BackupWaitWalArchive"; + break; /* no default case, so that compiler will warn */ } diff --git a/src/include/pgstat.h b/src/include/pgstat.h index aecb6013f0..7c40ebc3dc 100644 --- a/src/include/pgstat.h +++ b/src/include/pgstat.h @@ -853,7 +853,8 @@ typedef enum WAIT_EVENT_REPLICATION_ORIGIN_DROP, WAIT_EVENT_REPLICATION_SLOT_DROP, WAIT_EVENT_SAFE_SNAPSHOT, - WAIT_EVENT_SYNC_REP + WAIT_EVENT_SYNC_REP, + WAIT_EVENT_BACKUP_WAIT_WAL_ARCHIVE } WaitEventIPC; /* ---------- --------------41888754B6F946B7A27666BE--