* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.174 2004/10/14 20:23:43 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.175 2004/10/29 00:16:08 tgl Exp $
*
*-------------------------------------------------------------------------
*/
static int XLogFileRead(uint32 log, uint32 seg, int emode);
static bool RestoreArchivedFile(char *path, const char *xlogfname,
const char *recovername, off_t expectedSize);
-static void PreallocXlogFiles(XLogRecPtr endptr);
-static void MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr);
+static int PreallocXlogFiles(XLogRecPtr endptr);
+static void MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr,
+ int *nsegsremoved, int *nsegsrecycled);
static XLogRecord *ReadRecord(XLogRecPtr *RecPtr, int emode);
static bool ValidXLOGHeader(XLogPageHeader hdr, int emode);
static XLogRecord *ReadCheckpointRecord(XLogRecPtr RecPtr, int whichChkpt);
* Preallocate log files beyond the specified log endpoint, according to
* the XLOGfile user parameter.
*/
-static void
+static int
PreallocXlogFiles(XLogRecPtr endptr)
{
+ int nsegsadded = 0;
uint32 _logId;
uint32 _logSeg;
int lf;
use_existent = true;
lf = XLogFileInit(_logId, _logSeg, &use_existent, true);
close(lf);
+ if (!use_existent)
+ nsegsadded++;
}
+ return nsegsadded;
}
/*
* whether we want to recycle rather than delete no-longer-wanted log files.
*/
static void
-MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr)
+MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr,
+ int *nsegsremoved, int *nsegsrecycled)
{
uint32 endlogId;
uint32 endlogSeg;
char lastoff[MAXFNAMELEN];
char path[MAXPGPATH];
+ *nsegsremoved = 0;
+ *nsegsrecycled = 0;
+
XLByteToPrevSeg(endptr, endlogId, endlogSeg);
xldir = AllocateDir(XLogDir);
true, XLOGfileslop,
true))
{
- ereport(DEBUG1,
+ ereport(DEBUG2,
(errmsg("recycled transaction log file \"%s\"",
xlde->d_name)));
+ (*nsegsrecycled)++;
}
else
{
/* No need for any more future segments... */
- ereport(DEBUG1,
+ ereport(DEBUG2,
(errmsg("removing transaction log file \"%s\"",
xlde->d_name)));
unlink(path);
+ (*nsegsremoved)++;
}
XLogArchiveCleanup(xlde->d_name);
/*
* Preallocate additional log files, if wanted.
*/
- PreallocXlogFiles(EndOfLog);
+ (void) PreallocXlogFiles(EndOfLog);
/*
* Okay, we're officially UP.
uint32 freespace;
uint32 _logId;
uint32 _logSeg;
+ int nsegsadded = 0;
+ int nsegsremoved = 0;
+ int nsegsrecycled = 0;
/*
* Acquire CheckpointLock to ensure only one checkpoint happens at a
*/
END_CRIT_SECTION();
+ if (!shutdown)
+ ereport(DEBUG1,
+ (errmsg("checkpoint starting")));
+
CheckPointCLOG();
CheckPointSUBTRANS();
FlushBufferPool();
if (_logId || _logSeg)
{
PrevLogSeg(_logId, _logSeg);
- MoveOfflineLogs(_logId, _logSeg, recptr);
+ MoveOfflineLogs(_logId, _logSeg, recptr,
+ &nsegsremoved, &nsegsrecycled);
}
/*
* necessary.)
*/
if (!shutdown)
- PreallocXlogFiles(recptr);
+ nsegsadded = PreallocXlogFiles(recptr);
/*
* Truncate pg_subtrans if possible. We can throw away all data
if (!InRecovery)
TruncateSUBTRANS(GetOldestXmin(true));
+ if (!shutdown)
+ ereport(DEBUG1,
+ (errmsg("checkpoint complete; %d transaction log file(s) added, %d removed, %d recycled",
+ nsegsadded, nsegsremoved, nsegsrecycled)));
+
LWLockRelease(CheckpointLock);
}