1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-31 17:02:12 +03:00

Recursively fsync() the data directory after a crash.

Otherwise, if there's another crash, some writes from after the first
crash might make it to disk while writes from before the crash fail
to make it to disk.  This could lead to data corruption.

Back-patch to all supported versions.

Abhijit Menon-Sen, reviewed by Andres Freund and slightly revised
by me.
This commit is contained in:
Robert Haas
2015-05-04 14:13:53 -04:00
parent ec3d976bce
commit 2ce439f337
3 changed files with 159 additions and 0 deletions

View File

@@ -114,6 +114,8 @@ extern int pg_fsync_writethrough(int fd);
extern int pg_fdatasync(int fd);
extern int pg_flush_data(int fd, off_t offset, off_t amount);
extern void fsync_fname(char *fname, bool isdir);
extern void pre_sync_fname(char *fname, bool isdir);
extern void walkdir(char *path, void (*action) (char *fname, bool isdir));
/* Filename components for OpenTemporaryFile */
#define PG_TEMP_FILES_DIR "pgsql_tmp"