Use WaitLatch() instead of pg_usleep() at the end of backups

This concerns pg_stop_backup() and BASE_BACKUP, when waiting for the
WAL segments required for a backup to be archived.  This simplifies a
bit the handling of the wait event used in this code path.

Author: Bharath Rupireddy
Reviewed-by: Michael Paquier, Stephen Frost
Discussion: https://postgr.es/m/CALj2ACU4AdPCq6NLfcA-ZGwX7pPCK5FgEj-CAU0xCKzkASSy_A@mail.gmail.com
This commit is contained in:
Michael Paquier 2021-07-06 08:10:59 +09:00
parent 9753324b7d
commit 2aca19f298

View file

@ -11638,9 +11638,11 @@ do_pg_stop_backup(char *labelfile, bool waitforarchive, TimeLineID *stoptli_p)
reported_waiting = true; reported_waiting = true;
} }
pgstat_report_wait_start(WAIT_EVENT_BACKUP_WAIT_WAL_ARCHIVE); (void) WaitLatch(MyLatch,
pg_usleep(1000000L); WL_LATCH_SET | WL_TIMEOUT | WL_EXIT_ON_PM_DEATH,
pgstat_report_wait_end(); 1000L,
WAIT_EVENT_BACKUP_WAIT_WAL_ARCHIVE);
ResetLatch(MyLatch);
if (++waits >= seconds_before_warning) if (++waits >= seconds_before_warning)
{ {