aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2009-06-02 06:18:06 +0000
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2009-06-02 06:18:06 +0000
commit7c8d7a2eec1bc1aa1332a5b6a6d3d03c594dc6cd (patch)
treea62ce6e078ce0b284c51cca8c1809062c3a65dbe /src/backend/access
parentdb020733059dd6eb3fa400dd8d80bfad0d19c71f (diff)
downloadpostgresql-7c8d7a2eec1bc1aa1332a5b6a6d3d03c594dc6cd.tar.gz
postgresql-7c8d7a2eec1bc1aa1332a5b6a6d3d03c594dc6cd.zip
Only recycle normal files in pg_xlog as WAL segments. pg_standby creates
symbolic links with the -l option, and as Fujii Masao pointed out we ended up overwriting files in the archive directory before this patch. Patch by Aidan Van Dyk, Fujii Masao and me. Backpatch to 8.3, where pg_standby was introduced.
Diffstat (limited to 'src/backend/access')
-rw-r--r--src/backend/access/transam/xlog.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index ecf5046ff9a..b6171c78c01 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.341 2009/05/28 11:02:16 heikki Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.342 2009/06/02 06:18:06 heikki Exp $
*
*-------------------------------------------------------------------------
*/
@@ -3006,6 +3006,7 @@ RemoveOldXlogFiles(uint32 log, uint32 seg, XLogRecPtr endptr)
struct dirent *xlde;
char lastoff[MAXFNAMELEN];
char path[MAXPGPATH];
+ struct stat statbuf;
/*
* Initialize info about where to try to recycle to. We allow recycling
@@ -3046,11 +3047,13 @@ RemoveOldXlogFiles(uint32 log, uint32 seg, XLogRecPtr endptr)
/*
* Before deleting the file, see if it can be recycled as a
- * future log segment.
+ * future log segment. Only recycle normal files, pg_standby
+ * for example can create symbolic links pointing to a
+ * separate archive directory.
*/
- if (InstallXLogFileSegment(&endlogId, &endlogSeg, path,
- true, &max_advance,
- true))
+ if (lstat(path, &statbuf) == 0 && S_ISREG(statbuf.st_mode) &&
+ InstallXLogFileSegment(&endlogId, &endlogSeg, path,
+ true, &max_advance, true))
{
ereport(DEBUG2,
(errmsg("recycled transaction log file \"%s\"",