summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2010-08-16 17:33:30 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2010-08-16 17:33:30 +0000
commit28d27cfdc9f5b18b8695429601bf2440fec17142 (patch)
tree55977746b6ebd26119c6ee97afb5e5cd34277168
parent9217dee11811b37495766c58e4f67c9b3461c962 (diff)
Arrange to fsync the contents of lockfiles (both postmaster.pid and the
socket lockfile) when writing them. The lack of an fsync here may well explain two different reports we've seen of corrupted lockfile contents, which doesn't particularly bother the running server but can prevent a new server from starting if the old one crashes. Per suggestion from Alvaro. Back-patch to all supported versions.
-rw-r--r--src/backend/utils/init/miscinit.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c
index 614f0a205fd..3f2212d3745 100644
--- a/src/backend/utils/init/miscinit.c
+++ b/src/backend/utils/init/miscinit.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.116.2.2 2009/12/09 21:59:07 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.116.2.3 2010/08/16 17:33:30 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -721,6 +721,7 @@ CreateLockFile(const char *filename, bool amPostmaster,
(errcode_for_file_access(),
errmsg("could not write lock file \"%s\": %m", filename)));
}
+ pg_fsync(fd);
close(fd);
/*
@@ -875,6 +876,7 @@ RecordSharedMemoryInLockFile(unsigned long id1, unsigned long id2)
close(fd);
return;
}
+ pg_fsync(fd);
close(fd);
}