Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit756e221

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 thisrename to disk accounts for a significant amount of the overheadassociated with archiving. While durably renaming the fileprevents re-archiving in most cases, archive commands and librariesmust already gracefully handle attempts to re-archive the lastarchived file after a crash (e.g., a crash immediately afterarchive_command exits but before the server renames the statusfile).This change reduces the amount of overhead associated witharchiving by using rename() instead of durable_rename() to renamethe archive status files. As a consequence, the server is morelikely to attempt to re-archive files after a crash, but as notedabove, archive commands and modules are already expected to handlethis. It is also possible that the server will attempt to re-archive files that have been removed or recycled, but the archiveralready handles this, too.Author: Nathan BossartReviewed-by: Kyotaro Horiguchi, Fujii MasaoDiscussion:https://postgr.es/m/20220222011948.GA3850532@nathanxps13
1 parent27e0ee5 commit756e221

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)

[8]ページ先頭

©2009-2025 Movatter.jp