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

Commitff5a354

Browse files
committed
Fix is-it-time-for-a-checkpoint logic so that checkpoint_segments can
usefully be larger than 255. Per gripe from Simon Riggs.
1 parent24658a2 commitff5a354

File tree

1 file changed

+26
-9
lines changed
  • src/backend/access/transam

1 file changed

+26
-9
lines changed

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

Lines changed: 26 additions & 9 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.178 2004/11/1716:26:59 tgl Exp $
10+
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.179 2004/12/1700:10:36 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -1201,21 +1201,38 @@ XLogWrite(XLogwrtRqst WriteRqst)
12011201
UpdateControlFile();
12021202

12031203
/*
1204-
* Signalpostmaster to start a checkpoint if it's been
1204+
* Signalbgwriter to start a checkpoint if it's been
12051205
* too long since the last one. (We look at local copy of
12061206
* RedoRecPtr which might be a little out of date, but
12071207
* should be close enough for this purpose.)
1208+
*
1209+
* A straight computation of segment number could overflow
1210+
* 32 bits. Rather than assuming we have working 64-bit
1211+
* arithmetic, we compare the highest-order bits separately,
1212+
* and force a checkpoint immediately when they change.
12081213
*/
1209-
if (IsUnderPostmaster&&
1210-
(openLogId!=RedoRecPtr.xlogid||
1211-
openLogSeg >= (RedoRecPtr.xrecoff /XLogSegSize)+
1212-
(uint32)CheckPointSegments))
1214+
if (IsUnderPostmaster)
12131215
{
1216+
uint32old_segno,
1217+
new_segno;
1218+
uint32old_highbits,
1219+
new_highbits;
1220+
1221+
old_segno= (RedoRecPtr.xlogid %XLogSegSize)*XLogSegsPerFile+
1222+
(RedoRecPtr.xrecoff /XLogSegSize);
1223+
old_highbits=RedoRecPtr.xlogid /XLogSegSize;
1224+
new_segno= (openLogId %XLogSegSize)*XLogSegsPerFile+
1225+
openLogSeg;
1226+
new_highbits=openLogId /XLogSegSize;
1227+
if (new_highbits!=old_highbits||
1228+
new_segno >=old_segno+ (uint32)CheckPointSegments)
1229+
{
12141230
#ifdefWAL_DEBUG
1215-
if (XLOG_DEBUG)
1216-
elog(LOG,"time for a checkpoint, signaling bgwriter");
1231+
if (XLOG_DEBUG)
1232+
elog(LOG,"time for a checkpoint, signaling bgwriter");
12171233
#endif
1218-
RequestCheckpoint(false);
1234+
RequestCheckpoint(false);
1235+
}
12191236
}
12201237
}
12211238
LWLockRelease(ControlFileLock);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp