Skip to content

Commit aca7484

Browse files
committed
Fix missing fsync of SLRU directories.
Harmonize behavior by moving reponsibility for fsyncing directories down into slru.c. In 10 and later, only the multixact directories were missed (see commit 1b02be2), and in older branches all SLRUs were missed. Back-patch to all supported releases. Reviewed-by: Andres Freund <andres@anarazel.de> Reviewed-by: Michael Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/CA%2BhUKGLtsTUOScnNoSMZ-2ZLv%2BwGh01J6kAo_DM8mTRq1sKdSQ%40mail.gmail.com
1 parent 6b2c4e5 commit aca7484

File tree

3 files changed

+4
-13
lines changed

3 files changed

+4
-13
lines changed

src/backend/access/transam/clog.c

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -836,13 +836,6 @@ CheckPointCLOG(void)
836836
/* Flush dirty CLOG pages to disk */
837837
TRACE_POSTGRESQL_CLOG_CHECKPOINT_START(true);
838838
SimpleLruFlush(XactCtl, true);
839-
840-
/*
841-
* fsync pg_xact to ensure that any files flushed previously are durably
842-
* on disk.
843-
*/
844-
fsync_fname("pg_xact", true);
845-
846839
TRACE_POSTGRESQL_CLOG_CHECKPOINT_DONE(true);
847840
}
848841

src/backend/access/transam/commit_ts.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -822,12 +822,6 @@ CheckPointCommitTs(void)
822822
{
823823
/* Flush dirty CommitTs pages to disk */
824824
SimpleLruFlush(CommitTsCtl, true);
825-
826-
/*
827-
* fsync pg_commit_ts to ensure that any files flushed previously are
828-
* durably on disk.
829-
*/
830-
fsync_fname("pg_commit_ts", true);
831825
}
832826

833827
/*

src/backend/access/transam/slru.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,6 +1187,10 @@ SimpleLruFlush(SlruCtl ctl, bool allow_redirtied)
11871187
}
11881188
if (!ok)
11891189
SlruReportIOError(ctl, pageno, InvalidTransactionId);
1190+
1191+
/* Ensure that directory entries for new files are on disk. */
1192+
if (ctl->do_fsync)
1193+
fsync_fname(ctl->Dir, true);
11901194
}
11911195

11921196
/*

0 commit comments

Comments
 (0)