Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitee69be4

Browse files
committed
Add DEBUG1-level logging of checkpoint start and end. Also, reduce the
'recycled log files' and 'removed log files' messages from DEBUG1 toDEBUG2, replacing them with a count of files added/removed/recycled inthe checkpoint end message, as per suggestion from Simon Riggs.
1 parentfe2bfa6 commitee69be4

File tree

1 file changed

+34
-10
lines changed
  • src/backend/access/transam

1 file changed

+34
-10
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
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 $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -442,8 +442,9 @@ static intXLogFileOpen(uint32 log, uint32 seg);
442442
staticintXLogFileRead(uint32log,uint32seg,intemode);
443443
staticboolRestoreArchivedFile(char*path,constchar*xlogfname,
444444
constchar*recovername,off_texpectedSize);
445-
staticvoidPreallocXlogFiles(XLogRecPtrendptr);
446-
staticvoidMoveOfflineLogs(uint32log,uint32seg,XLogRecPtrendptr);
445+
staticintPreallocXlogFiles(XLogRecPtrendptr);
446+
staticvoidMoveOfflineLogs(uint32log,uint32seg,XLogRecPtrendptr,
447+
int*nsegsremoved,int*nsegsrecycled);
447448
staticXLogRecord*ReadRecord(XLogRecPtr*RecPtr,intemode);
448449
staticboolValidXLOGHeader(XLogPageHeaderhdr,intemode);
449450
staticXLogRecord*ReadCheckpointRecord(XLogRecPtrRecPtr,intwhichChkpt);
@@ -2067,9 +2068,10 @@ RestoreArchivedFile(char *path, const char *xlogfname,
20672068
* Preallocate log files beyond the specified log endpoint, according to
20682069
* the XLOGfile user parameter.
20692070
*/
2070-
staticvoid
2071+
staticint
20712072
PreallocXlogFiles(XLogRecPtrendptr)
20722073
{
2074+
intnsegsadded=0;
20732075
uint32_logId;
20742076
uint32_logSeg;
20752077
intlf;
@@ -2083,7 +2085,10 @@ PreallocXlogFiles(XLogRecPtr endptr)
20832085
use_existent= true;
20842086
lf=XLogFileInit(_logId,_logSeg,&use_existent, true);
20852087
close(lf);
2088+
if (!use_existent)
2089+
nsegsadded++;
20862090
}
2091+
returnnsegsadded;
20872092
}
20882093

20892094
/*
@@ -2093,7 +2098,8 @@ PreallocXlogFiles(XLogRecPtr endptr)
20932098
* whether we want to recycle rather than delete no-longer-wanted log files.
20942099
*/
20952100
staticvoid
2096-
MoveOfflineLogs(uint32log,uint32seg,XLogRecPtrendptr)
2101+
MoveOfflineLogs(uint32log,uint32seg,XLogRecPtrendptr,
2102+
int*nsegsremoved,int*nsegsrecycled)
20972103
{
20982104
uint32endlogId;
20992105
uint32endlogSeg;
@@ -2102,6 +2108,9 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr)
21022108
charlastoff[MAXFNAMELEN];
21032109
charpath[MAXPGPATH];
21042110

2111+
*nsegsremoved=0;
2112+
*nsegsrecycled=0;
2113+
21052114
XLByteToPrevSeg(endptr,endlogId,endlogSeg);
21062115

21072116
xldir=AllocateDir(XLogDir);
@@ -2152,17 +2161,19 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr)
21522161
true,XLOGfileslop,
21532162
true))
21542163
{
2155-
ereport(DEBUG1,
2164+
ereport(DEBUG2,
21562165
(errmsg("recycled transaction log file \"%s\"",
21572166
xlde->d_name)));
2167+
(*nsegsrecycled)++;
21582168
}
21592169
else
21602170
{
21612171
/* No need for any more future segments... */
2162-
ereport(DEBUG1,
2172+
ereport(DEBUG2,
21632173
(errmsg("removing transaction log file \"%s\"",
21642174
xlde->d_name)));
21652175
unlink(path);
2176+
(*nsegsremoved)++;
21662177
}
21672178

21682179
XLogArchiveCleanup(xlde->d_name);
@@ -4470,7 +4481,7 @@ StartupXLOG(void)
44704481
/*
44714482
* Preallocate additional log files, if wanted.
44724483
*/
4473-
PreallocXlogFiles(EndOfLog);
4484+
(void)PreallocXlogFiles(EndOfLog);
44744485

44754486
/*
44764487
* Okay, we're officially UP.
@@ -4694,6 +4705,9 @@ CreateCheckPoint(bool shutdown, bool force)
46944705
uint32freespace;
46954706
uint32_logId;
46964707
uint32_logSeg;
4708+
intnsegsadded=0;
4709+
intnsegsremoved=0;
4710+
intnsegsrecycled=0;
46974711

46984712
/*
46994713
* Acquire CheckpointLock to ensure only one checkpoint happens at a
@@ -4861,6 +4875,10 @@ CreateCheckPoint(bool shutdown, bool force)
48614875
*/
48624876
END_CRIT_SECTION();
48634877

4878+
if (!shutdown)
4879+
ereport(DEBUG1,
4880+
(errmsg("checkpoint starting")));
4881+
48644882
CheckPointCLOG();
48654883
CheckPointSUBTRANS();
48664884
FlushBufferPool();
@@ -4936,7 +4954,8 @@ CreateCheckPoint(bool shutdown, bool force)
49364954
if (_logId||_logSeg)
49374955
{
49384956
PrevLogSeg(_logId,_logSeg);
4939-
MoveOfflineLogs(_logId,_logSeg,recptr);
4957+
MoveOfflineLogs(_logId,_logSeg,recptr,
4958+
&nsegsremoved,&nsegsrecycled);
49404959
}
49414960

49424961
/*
@@ -4945,7 +4964,7 @@ CreateCheckPoint(bool shutdown, bool force)
49454964
* necessary.)
49464965
*/
49474966
if (!shutdown)
4948-
PreallocXlogFiles(recptr);
4967+
nsegsadded=PreallocXlogFiles(recptr);
49494968

49504969
/*
49514970
* Truncate pg_subtrans if possible. We can throw away all data
@@ -4957,6 +4976,11 @@ CreateCheckPoint(bool shutdown, bool force)
49574976
if (!InRecovery)
49584977
TruncateSUBTRANS(GetOldestXmin(true));
49594978

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+
49604984
LWLockRelease(CheckpointLock);
49614985
}
49624986

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp