1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +03:00

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.
This commit is contained in:
Magnus Hagander
2010-06-09 10:54:53 +00:00
parent b52f12b3a5
commit 6a318a1827

View File

@@ -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.345.2.8 2010/03/18 09:18:54 heikki Exp $
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.345.2.9 2010/06/09 10:54:53 mha Exp $
*
*-------------------------------------------------------------------------
*/
@@ -2038,9 +2038,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)