aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlog.c
diff options
context:
space:
mode:
authorMagnus Hagander <magnus@hagander.net>2010-06-09 10:54:45 +0000
committerMagnus Hagander <magnus@hagander.net>2010-06-09 10:54:45 +0000
commit8c873bbfa723e4d035847a488adbd0aa21c595b9 (patch)
tree41e2843750b179211eb4a093babc838a2db1d5e2 /src/backend/access/transam/xlog.c
parent5a41c317c58603e1beff5f2f31e157a30f41a3bf (diff)
downloadpostgresql-8c873bbfa723e4d035847a488adbd0aa21c595b9.tar.gz
postgresql-8c873bbfa723e4d035847a488adbd0aa21c595b9.zip
Make the walwriter close it's handle to an old xlog segment if it's no longer
the current one. Not doing this would leave the walwriter with a handle to a deleted file if there was nothing for it to do for a long period of time, preventing the file from being completely removed. Reported by Tollef Fog Heen, and thanks to Heikki for some hand-holding with the patch.
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r--src/backend/access/transam/xlog.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 3024d1695e6..19f812456e9 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.417 2010/06/03 21:02:11 petere Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.418 2010/06/09 10:54:45 mha Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2124,9 +2124,21 @@ XLogBackgroundFlush(void)
flexible = false; /* ensure it all gets written */
}
- /* Done if already known flushed */
+ /*
+ * If already known flushed, we're done. Just need to check if we
+ * are holding an open file handle to a logfile that's no longer
+ * in use, preventing the file from being deleted.
+ */
if (XLByteLE(WriteRqstPtr, LogwrtResult.Flush))
+ {
+ if (openLogFile >= 0) {
+ if (!XLByteInPrevSeg(LogwrtResult.Write, openLogId, openLogSeg))
+ {
+ XLogFileClose();
+ }
+ }
return;
+ }
#ifdef WAL_DEBUG
if (XLOG_DEBUG)