From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: pgsql-hackers@postgresql.org
Subject: Re: Wait event that should be reported while waiting for WAL archiving to finish
Date: Thu, 13 Feb 2020 15:35:50 +0900
Message-ID: <949931aa-4ed4-d867-a7b5-de9c02b2292b@oss.nttdata.com> (raw)
In-Reply-To: <20200213032804.GB1520@paquier.xyz>
References: <f0651f8c-9c96-9f29-0ff9-80414a15308a@oss.nttdata.com>
<20200213032804.GB1520@paquier.xyz>
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
Attachments:wait_event_wal_archive_v1.patch (text/plain, 2.4K) downloaddiff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgmlindex 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
<entry><literal>SyncRep</literal></entry>
<entry>Waiting for confirmation from remote server during synchronous replication.</entry>
</row>
+ <row>+ <entry><literal>BackupWaitWalArchive</literal></entry>+ <entry>Waiting for WAL files required for the backup to be successfully archived.</entry>+ </row>
<row>
<entry morerows="2"><literal>Timeout</literal></entry>
<entry><literal>BaseBackupThrottle</literal></entry>
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.cindex 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.cindex 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.hindex 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;
/* ----------
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: masao.fujii@oss.nttdata.com, michael@paquier.xyz
Subject: Re: Wait event that should be reported while waiting for WAL archiving to finish
In-Reply-To: <949931aa-4ed4-d867-a7b5-de9c02b2292b@oss.nttdata.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox