7
7
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
8
8
* Portions Copyright (c) 1994, Regents of the University of California
9
9
*
10
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.174 2004/10/14 20:23:43 momjian Exp $
10
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.175 2004/10/29 00:16:08 tgl Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -442,8 +442,9 @@ static int XLogFileOpen(uint32 log, uint32 seg);
442
442
static int XLogFileRead (uint32 log , uint32 seg , int emode );
443
443
static bool RestoreArchivedFile (char * path , const char * xlogfname ,
444
444
const char * recovername , off_t expectedSize );
445
- static void PreallocXlogFiles (XLogRecPtr endptr );
446
- static void MoveOfflineLogs (uint32 log , uint32 seg , XLogRecPtr endptr );
445
+ static int PreallocXlogFiles (XLogRecPtr endptr );
446
+ static void MoveOfflineLogs (uint32 log , uint32 seg , XLogRecPtr endptr ,
447
+ int * nsegsremoved , int * nsegsrecycled );
447
448
static XLogRecord * ReadRecord (XLogRecPtr * RecPtr , int emode );
448
449
static bool ValidXLOGHeader (XLogPageHeader hdr , int emode );
449
450
static XLogRecord * ReadCheckpointRecord (XLogRecPtr RecPtr , int whichChkpt );
@@ -2067,9 +2068,10 @@ RestoreArchivedFile(char *path, const char *xlogfname,
2067
2068
* Preallocate log files beyond the specified log endpoint, according to
2068
2069
* the XLOGfile user parameter.
2069
2070
*/
2070
- static void
2071
+ static int
2071
2072
PreallocXlogFiles (XLogRecPtr endptr )
2072
2073
{
2074
+ int nsegsadded = 0 ;
2073
2075
uint32 _logId ;
2074
2076
uint32 _logSeg ;
2075
2077
int lf ;
@@ -2083,7 +2085,10 @@ PreallocXlogFiles(XLogRecPtr endptr)
2083
2085
use_existent = true;
2084
2086
lf = XLogFileInit (_logId , _logSeg , & use_existent , true);
2085
2087
close (lf );
2088
+ if (!use_existent )
2089
+ nsegsadded ++ ;
2086
2090
}
2091
+ return nsegsadded ;
2087
2092
}
2088
2093
2089
2094
/*
@@ -2093,7 +2098,8 @@ PreallocXlogFiles(XLogRecPtr endptr)
2093
2098
* whether we want to recycle rather than delete no-longer-wanted log files.
2094
2099
*/
2095
2100
static void
2096
- MoveOfflineLogs (uint32 log , uint32 seg , XLogRecPtr endptr )
2101
+ MoveOfflineLogs (uint32 log , uint32 seg , XLogRecPtr endptr ,
2102
+ int * nsegsremoved , int * nsegsrecycled )
2097
2103
{
2098
2104
uint32 endlogId ;
2099
2105
uint32 endlogSeg ;
@@ -2102,6 +2108,9 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr)
2102
2108
char lastoff [MAXFNAMELEN ];
2103
2109
char path [MAXPGPATH ];
2104
2110
2111
+ * nsegsremoved = 0 ;
2112
+ * nsegsrecycled = 0 ;
2113
+
2105
2114
XLByteToPrevSeg (endptr , endlogId , endlogSeg );
2106
2115
2107
2116
xldir = AllocateDir (XLogDir );
@@ -2152,17 +2161,19 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr)
2152
2161
true, XLOGfileslop ,
2153
2162
true))
2154
2163
{
2155
- ereport (DEBUG1 ,
2164
+ ereport (DEBUG2 ,
2156
2165
(errmsg ("recycled transaction log file \"%s\"" ,
2157
2166
xlde -> d_name )));
2167
+ (* nsegsrecycled )++ ;
2158
2168
}
2159
2169
else
2160
2170
{
2161
2171
/* No need for any more future segments... */
2162
- ereport (DEBUG1 ,
2172
+ ereport (DEBUG2 ,
2163
2173
(errmsg ("removing transaction log file \"%s\"" ,
2164
2174
xlde -> d_name )));
2165
2175
unlink (path );
2176
+ (* nsegsremoved )++ ;
2166
2177
}
2167
2178
2168
2179
XLogArchiveCleanup (xlde -> d_name );
@@ -4470,7 +4481,7 @@ StartupXLOG(void)
4470
4481
/*
4471
4482
* Preallocate additional log files, if wanted.
4472
4483
*/
4473
- PreallocXlogFiles (EndOfLog );
4484
+ ( void ) PreallocXlogFiles (EndOfLog );
4474
4485
4475
4486
/*
4476
4487
* Okay, we're officially UP.
@@ -4694,6 +4705,9 @@ CreateCheckPoint(bool shutdown, bool force)
4694
4705
uint32 freespace ;
4695
4706
uint32 _logId ;
4696
4707
uint32 _logSeg ;
4708
+ int nsegsadded = 0 ;
4709
+ int nsegsremoved = 0 ;
4710
+ int nsegsrecycled = 0 ;
4697
4711
4698
4712
/*
4699
4713
* Acquire CheckpointLock to ensure only one checkpoint happens at a
@@ -4861,6 +4875,10 @@ CreateCheckPoint(bool shutdown, bool force)
4861
4875
*/
4862
4876
END_CRIT_SECTION ();
4863
4877
4878
+ if (!shutdown )
4879
+ ereport (DEBUG1 ,
4880
+ (errmsg ("checkpoint starting" )));
4881
+
4864
4882
CheckPointCLOG ();
4865
4883
CheckPointSUBTRANS ();
4866
4884
FlushBufferPool ();
@@ -4936,7 +4954,8 @@ CreateCheckPoint(bool shutdown, bool force)
4936
4954
if (_logId || _logSeg )
4937
4955
{
4938
4956
PrevLogSeg (_logId , _logSeg );
4939
- MoveOfflineLogs (_logId , _logSeg , recptr );
4957
+ MoveOfflineLogs (_logId , _logSeg , recptr ,
4958
+ & nsegsremoved , & nsegsrecycled );
4940
4959
}
4941
4960
4942
4961
/*
@@ -4945,7 +4964,7 @@ CreateCheckPoint(bool shutdown, bool force)
4945
4964
* necessary.)
4946
4965
*/
4947
4966
if (!shutdown )
4948
- PreallocXlogFiles (recptr );
4967
+ nsegsadded = PreallocXlogFiles (recptr );
4949
4968
4950
4969
/*
4951
4970
* Truncate pg_subtrans if possible. We can throw away all data
@@ -4957,6 +4976,11 @@ CreateCheckPoint(bool shutdown, bool force)
4957
4976
if (!InRecovery )
4958
4977
TruncateSUBTRANS (GetOldestXmin (true));
4959
4978
4979
+ if (!shutdown )
4980
+ ereport (DEBUG1 ,
4981
+ (errmsg ("checkpoint complete; %d transaction log file(s) added, %d removed, %d recycled" ,
4982
+ nsegsadded , nsegsremoved , nsegsrecycled )));
4983
+
4960
4984
LWLockRelease (CheckpointLock );
4961
4985
}
4962
4986
0 commit comments