walwriter.patch
application/octet-stream
Filename: walwriter.patch
Type: application/octet-stream
Part: 0
Message:
walwriter not closing old files
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/backend/access/transam/xlog.c | 13 | 1 |
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 8f95f02..cc4b26b 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -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)