1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-10 17:42:29 +03:00

Improve performance of pgarch_readyXlog() with many status files.

Presently, the archive_status directory was scanned for each file to
archive.  When there are many status files, say because archive_command
has been failing for a long time, these directory scans can get very
slow.  With this change, the archiver remembers several files to archive
during each directory scan, speeding things up.

To ensure timeline history files are archived as quickly as possible,
XLogArchiveNotify() forces the archiver to do a new directory scan as
soon as the .ready file for one is created.

Nathan Bossart, per a long discussion involving many people. It is
not clear to me exactly who out of all those people reviewed this
particular patch.

Discussion: http://postgr.es/m/CA+TgmobhAbs2yabTuTRkJTq_kkC80-+jw=pfpypdOJ7+gAbQbw@mail.gmail.com
Discussion: http://postgr.es/m/620F3CE1-0255-4D66-9D87-0EADE866985A@amazon.com
This commit is contained in:
Robert Haas
2021-11-11 15:02:53 -05:00
parent 01ec41a5fe
commit beb4e9ba16
3 changed files with 182 additions and 26 deletions

View File

@@ -489,6 +489,20 @@ XLogArchiveNotify(const char *xlog)
return;
}
/*
* Timeline history files are given the highest archival priority to
* lower the chance that a promoted standby will choose a timeline that
* is already in use. However, the archiver ordinarily tries to gather
* multiple files to archive from each scan of the archive_status
* directory, which means that newly created timeline history files
* could be left unarchived for a while. To ensure that the archiver
* picks up timeline history files as soon as possible, we force the
* archiver to scan the archive_status directory the next time it looks
* for a file to archive.
*/
if (IsTLHistoryFileName(xlog))
PgArchForceDirScan();
/* Notify archiver that it's got something to do */
if (IsUnderPostmaster)
PgArchWakeup();