Skip to content

Commit b8e20d6

Browse files
committed
Add wait events for WAL archive and recovery pause.
This commit introduces new wait events BackupWaitWalArchive and RecoveryPause. The former is reported while waiting for the WAL files required for the backup to be successfully archived. The latter is reported while waiting for recovery in pause state to be resumed. Author: Fujii Masao Reviewed-by: Michael Paquier, Atsushi Torikoshi, Robert Haas Discussion: https://postgr.es/m/f0651f8c-9c96-9f29-0ff9-80414a15308a@oss.nttdata.com
1 parent 76df765 commit b8e20d6

File tree

4 files changed

+22
-2
lines changed

4 files changed

+22
-2
lines changed

doc/src/sgml/monitoring.sgml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1339,7 +1339,11 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
13391339
<entry>Waiting in an extension.</entry>
13401340
</row>
13411341
<row>
1342-
<entry morerows="36"><literal>IPC</literal></entry>
1342+
<entry morerows="38"><literal>IPC</literal></entry>
1343+
<entry><literal>BackupWaitWalArchive</literal></entry>
1344+
<entry>Waiting for WAL files required for the backup to be successfully archived.</entry>
1345+
</row>
1346+
<row>
13431347
<entry><literal>BgWorkerShutdown</literal></entry>
13441348
<entry>Waiting for background worker to shut down.</entry>
13451349
</row>
@@ -1471,6 +1475,10 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
14711475
<entry><literal>Promote</literal></entry>
14721476
<entry>Waiting for standby promotion.</entry>
14731477
</row>
1478+
<row>
1479+
<entry><literal>RecoveryPause</literal></entry>
1480+
<entry>Waiting for recovery to be resumed.</entry>
1481+
</row>
14741482
<row>
14751483
<entry><literal>ReplicationOriginDrop</literal></entry>
14761484
<entry>Waiting for a replication origin to become inactive to be dropped.</entry>

src/backend/access/transam/xlog.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5946,7 +5946,9 @@ recoveryPausesHere(void)
59465946

59475947
while (RecoveryIsPaused())
59485948
{
5949+
pgstat_report_wait_start(WAIT_EVENT_RECOVERY_PAUSE);
59495950
pg_usleep(1000000L); /* 1000 ms */
5951+
pgstat_report_wait_end();
59505952
HandleStartupProcInterrupts();
59515953
}
59525954
}
@@ -11146,7 +11148,9 @@ do_pg_stop_backup(char *labelfile, bool waitforarchive, TimeLineID *stoptli_p)
1114611148
reported_waiting = true;
1114711149
}
1114811150

11151+
pgstat_report_wait_start(WAIT_EVENT_BACKUP_WAIT_WAL_ARCHIVE);
1114911152
pg_usleep(1000000L);
11153+
pgstat_report_wait_end();
1115011154

1115111155
if (++waits >= seconds_before_warning)
1115211156
{

src/backend/postmaster/pgstat.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3682,6 +3682,9 @@ pgstat_get_wait_ipc(WaitEventIPC w)
36823682

36833683
switch (w)
36843684
{
3685+
case WAIT_EVENT_BACKUP_WAIT_WAL_ARCHIVE:
3686+
event_name = "BackupWaitWalArchive";
3687+
break;
36853688
case WAIT_EVENT_BGWORKER_SHUTDOWN:
36863689
event_name = "BgWorkerShutdown";
36873690
break;
@@ -3781,6 +3784,9 @@ pgstat_get_wait_ipc(WaitEventIPC w)
37813784
case WAIT_EVENT_PROMOTE:
37823785
event_name = "Promote";
37833786
break;
3787+
case WAIT_EVENT_RECOVERY_PAUSE:
3788+
event_name = "RecoveryPause";
3789+
break;
37843790
case WAIT_EVENT_REPLICATION_ORIGIN_DROP:
37853791
event_name = "ReplicationOriginDrop";
37863792
break;

src/include/pgstat.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,8 @@ typedef enum
798798
*/
799799
typedef enum
800800
{
801-
WAIT_EVENT_BGWORKER_SHUTDOWN = PG_WAIT_IPC,
801+
WAIT_EVENT_BACKUP_WAIT_WAL_ARCHIVE = PG_WAIT_IPC,
802+
WAIT_EVENT_BGWORKER_SHUTDOWN,
802803
WAIT_EVENT_BGWORKER_STARTUP,
803804
WAIT_EVENT_BTREE_PAGE,
804805
WAIT_EVENT_CLOG_GROUP_UPDATE,
@@ -831,6 +832,7 @@ typedef enum
831832
WAIT_EVENT_PARALLEL_FINISH,
832833
WAIT_EVENT_PROCARRAY_GROUP_UPDATE,
833834
WAIT_EVENT_PROMOTE,
835+
WAIT_EVENT_RECOVERY_PAUSE,
834836
WAIT_EVENT_REPLICATION_ORIGIN_DROP,
835837
WAIT_EVENT_REPLICATION_SLOT_DROP,
836838
WAIT_EVENT_SAFE_SNAPSHOT,

0 commit comments

Comments
 (0)