git.postgresql.org Git - postgresql.git/commitdiff

git projects / postgresql.git / commitdiff
? search:
summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5a41c31)
Make the walwriter close it's handle to an old xlog segment if it's no longer
Wed, 9 Jun 2010 10:54:45 +0000 (10:54 +0000)
Wed, 9 Jun 2010 10:54:45 +0000 (10:54 +0000)
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.


diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 3024d1695e6a21a582ddbdf74dd240816fe115ee..19f812456e94330547fc1a3b04d9d9254e0bbdf3 100644 (file)
--- 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)
This is the main PostgreSQL git repository.
RSS Atom

AltStyle によって変換されたページ (->オリジナル) /