|
8 | 8 | *
|
9 | 9 | *
|
10 | 10 | * IDENTIFICATION
|
11 |
| - * $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.150.2.3 2009/12/09 21:58:43 tgl Exp $ |
| 11 | + * $PostgreSQL: pgsql/src/backend/utils/init/miscinit.c,v 1.150.2.4 2010/08/16 17:33:17 tgl Exp $ |
12 | 12 | *
|
13 | 13 | *-------------------------------------------------------------------------
|
14 | 14 | */
|
@@ -899,6 +899,9 @@ CreateLockFile(const char *filename, bool amPostmaster,
|
899 | 899 | * admin) but has left orphan backends behind. Check for this by
|
900 | 900 | * looking to see if there is an associated shmem segment that is
|
901 | 901 | * still in use.
|
| 902 | + * |
| 903 | + * Note: because postmaster.pid is written in two steps, we might not |
| 904 | + * find the shmem ID values in it; we can't treat that as an error. |
902 | 905 | */
|
903 | 906 | if (isDDLock)
|
904 | 907 | {
|
@@ -963,7 +966,18 @@ CreateLockFile(const char *filename, bool amPostmaster,
|
963 | 966 | (errcode_for_file_access(),
|
964 | 967 | errmsg("c
F3EF
ould not write lock file \"%s\": %m", filename)));
|
965 | 968 | }
|
966 |
| - if (close(fd)) |
| 969 | + if (pg_fsync(fd) != 0) |
| 970 | + { |
| 971 | + int save_errno = errno; |
| 972 | + |
| 973 | + close(fd); |
| 974 | + unlink(filename); |
| 975 | + errno = save_errno; |
| 976 | + ereport(FATAL, |
| 977 | + (errcode_for_file_access(), |
| 978 | + errmsg("could not write lock file \"%s\": %m", filename))); |
| 979 | + } |
| 980 | + if (close(fd) != 0) |
967 | 981 | {
|
968 | 982 | int save_errno = errno;
|
969 | 983 |
|
@@ -1124,7 +1138,14 @@ RecordSharedMemoryInLockFile(unsigned long id1, unsigned long id2)
|
1124 | 1138 | close(fd);
|
1125 | 1139 | return;
|
1126 | 1140 | }
|
1127 |
| - if (close(fd)) |
| 1141 | + if (pg_fsync(fd) != 0) |
| 1142 | + { |
| 1143 | + ereport(LOG, |
| 1144 | + (errcode_for_file_access(), |
| 1145 | + errmsg("could not write to file \"%s\": %m", |
| 1146 | + DIRECTORY_LOCK_FILE))); |
| 1147 | + } |
| 1148 | + if (close(fd) != 0) |
1128 | 1149 | {
|
1129 | 1150 | ereport(LOG,
|
1130 | 1151 | (errcode_for_file_access(),
|
|
0 commit comments