diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2001-06-06 17:07:46 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2001-06-06 17:07:46 +0000 |
commit | 1173344e74f7b0eccb9bf3ad2307c82e12cb4fd8 (patch) | |
tree | 00c3aef112f9552cca8be339a7119d0541d73578 /src/backend/utils/init/miscinit.c | |
parent | ce370eec3555a48c05154fa2e3f102af9c851e1e (diff) |
Adjust WAL code so that checkpoints truncate the xlog at the previous
checkpoint's redo pointer, not its undo pointer, per discussion in
pghackers a few days ago. No point in hanging onto undo information
until we have the ability to do something with it --- and this solves
a rather large problem with log space for long-running transactions.
Also, change all calls of write() to detect the case where write
returned a count less than requested, but failed to set errno.
Presume that this situation indicates ENOSPC, and give the appropriate
error message, rather than a random message associated with the previous
value of errno.
Diffstat (limited to 'src/backend/utils/init/miscinit.c')
-rw-r--r-- | src/backend/utils/init/miscinit.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index 544b57ff1d6..91711b26c36 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.68 2001/06/01 20:27:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.69 2001/06/06 17:07:46 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -659,13 +659,15 @@ CreateLockFile(const char *filename, bool amPostmaster, snprintf(buffer, sizeof(buffer), "%d\n%s\n", amPostmaster ? (int) my_pid : -((int) my_pid), DataDir); + errno = 0; if (write(fd, buffer, strlen(buffer)) != strlen(buffer)) { int save_errno = errno; close(fd); unlink(filename); - errno = save_errno; + /* if write didn't set errno, assume problem is no disk space */ + errno = save_errno ? save_errno : ENOSPC; elog(FATAL, "Can't write lock file %s: %m", filename); } close(fd); @@ -794,9 +796,13 @@ RecordSharedMemoryInLockFile(IpcMemoryKey shmKey, IpcMemoryId shmId) * update should appear atomic to onlookers. */ len = strlen(buffer); + errno = 0; if (lseek(fd, (off_t) 0, SEEK_SET) != 0 || (int) write(fd, buffer, len) != len) { + /* if write didn't set errno, assume problem is no disk space */ + if (errno == 0) + errno = ENOSPC; elog(DEBUG, "Failed to write %s: %m", directoryLockFile); close(fd); return; |