Skip to content

Commit 756e221

Browse files
committed
Reduce overhead of renaming archive status files.
Presently, archive status files are durably renamed from .ready to .done to indicate that a file has been archived. Persisting this rename to disk accounts for a significant amount of the overhead associated with archiving. While durably renaming the file prevents re-archiving in most cases, archive commands and libraries must already gracefully handle attempts to re-archive the last archived file after a crash (e.g., a crash immediately after archive_command exits but before the server renames the status file). This change reduces the amount of overhead associated with archiving by using rename() instead of durable_rename() to rename the archive status files. As a consequence, the server is more likely to attempt to re-archive files after a crash, but as noted above, archive commands and modules are already expected to handle this. It is also possible that the server will attempt to re- archive files that have been removed or recycled, but the archiver already handles this, too. Author: Nathan Bossart Reviewed-by: Kyotaro Horiguchi, Fujii Masao Discussion: https://postgr.es/m/20220222011948.GA3850532@nathanxps13
1 parent 27e0ee5 commit 756e221

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/backend/postmaster/pgarch.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,19 @@ pgarch_archiveDone(char *xlog)
745745

746746
StatusFilePath(rlogready, xlog, ".ready");
747747
StatusFilePath(rlogdone, xlog, ".done");
748-
(void) durable_rename(rlogready, rlogdone, WARNING);
748+
749+
/*
750+
* To avoid extra overhead, we don't durably rename the .ready file to
751+
* .done. Archive commands and libraries must gracefully handle attempts
752+
* to re-archive files (e.g., if the server crashes just before this
753+
* function is called), so it should be okay if the .ready file reappears
754+
* after a crash.
755+
*/
756+
if (rename(rlogready, rlogdone) < 0)
757+
ereport(WARNING,
758+
(errcode_for_file_access(),
759+
errmsg("could not rename file \"%s\" to \"%s\": %m",
760+
rlogready, rlogdone)));
749761
}
750762

751763

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy