aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-01-25 03:06:04 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-01-25 03:06:04 +0000
commit80727ce14fe61a66e840d663e3b7d12c0a8380ad (patch)
tree64fc65d130165dc9656198936292288ef2d6a44b
parent7a196bab23032dfb1793a0ffce72bdc7b77f3b44 (diff)
downloadpostgresql-80727ce14fe61a66e840d663e3b7d12c0a8380ad.tar.gz
postgresql-80727ce14fe61a66e840d663e3b7d12c0a8380ad.zip
Use stat(2) to probe for existing xlog segments in InstallXLogFileSegment,
rather than actually opening the files. This eliminates some corner cases where the file indeed exists but open() fails for another reason, such as being out of file descriptors. The net reliability gain is probably tiny, since xlog.c is full of other file open calls that will elog(PANIC) if they fail for any reason; but this specific failure mode has been observed in the field, so we may as well fix it.
-rw-r--r--src/backend/access/transam/xlog.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index a78533c3890..c35762bba9e 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.110 2002/11/08 20:23:56 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.111 2003/01/25 03:06:04 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1471,7 +1471,7 @@ InstallXLogFileSegment(uint32 log, uint32 seg, char *tmppath,
bool use_lock)
{
char path[MAXPGPATH];
- int fd;
+ struct stat stat_buf;
XLogFileName(path, log, seg);
@@ -1489,10 +1489,8 @@ InstallXLogFileSegment(uint32 log, uint32 seg, char *tmppath,
else
{
/* Find a free slot to put it in */
- while ((fd = BasicOpenFile(path, O_RDWR | PG_BINARY,
- S_IRUSR | S_IWUSR)) >= 0)
+ while (stat(path, &stat_buf) == 0)
{
- close(fd);
if (--max_advance < 0)
{
/* Failed to find a free slot within specified range */