Hi, I'd like to propose to add new wait event reported while archiver process is executing archive_command. This would be helpful to observe what archiver is doing and check whether it has some troubles or not. Thought? PoC patch attached.
Also how about adding wait events for other commands like archive_cleanup_command, restore_command and recovery_end_command? Regards, -- Fujii Masao Advanced Computing Technology Center Research and Development Headquarters NTT DATA CORPORATION
diff --git a/doc/src/sgml/monitoring.sgml b/doc/src/sgml/monitoring.sgml index 3173ec2566..13c7e991d0 100644 --- a/doc/src/sgml/monitoring.sgml +++ b/doc/src/sgml/monitoring.sgml @@ -1569,7 +1569,12 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser <entry>Waiting for subplan nodes of an <literal>Append</literal> plan node to be ready.</entry> </row> - <row> + <row> + <entry><literal>ArchiveCommand</literal></entry> + <entry>Waiting for <xref linkend="guc-archive-command"/> to + complete.</entry> + </row> + <row> <entry><literal>BackendTermination</literal></entry> <entry>Waiting for the termination of another backend.</entry> </row> diff --git a/src/backend/postmaster/pgarch.c b/src/backend/postmaster/pgarch.c index 74a7d7c4d0..2201f069ea 100644 --- a/src/backend/postmaster/pgarch.c +++ b/src/backend/postmaster/pgarch.c @@ -515,7 +515,10 @@ pgarch_archiveXlog(char *xlog) snprintf(activitymsg, sizeof(activitymsg), "archiving %s", xlog); set_ps_display(activitymsg); + pgstat_report_wait_start(WAIT_EVENT_ARCHIVE_COMMAND); rc = system(xlogarchcmd); + pgstat_report_wait_end(); + if (rc != 0) { /* diff --git a/src/backend/utils/activity/wait_event.c b/src/backend/utils/activity/wait_event.c index 4a5b7502f5..d8e3688ab5 100644 --- a/src/backend/utils/activity/wait_event.c +++ b/src/backend/utils/activity/wait_event.c @@ -313,6 +313,9 @@ pgstat_get_wait_ipc(WaitEventIPC w) case WAIT_EVENT_APPEND_READY: event_name = "AppendReady"; break; + case WAIT_EVENT_ARCHIVE_COMMAND: + event_name = "ArchiveCommand"; + break; case WAIT_EVENT_BACKEND_TERMINATION: event_name = "BackendTermination"; break; diff --git a/src/include/utils/wait_event.h b/src/include/utils/wait_event.h index c22142365f..2edfdd3e51 100644 --- a/src/include/utils/wait_event.h +++ b/src/include/utils/wait_event.h @@ -80,6 +80,7 @@ typedef enum typedef enum { WAIT_EVENT_APPEND_READY = PG_WAIT_IPC, + WAIT_EVENT_ARCHIVE_COMMAND, WAIT_EVENT_BACKEND_TERMINATION, WAIT_EVENT_BACKUP_WAIT_WAL_ARCHIVE, WAIT_EVENT_BGWORKER_SHUTDOWN,