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

Commit8cf63ba

Browse files
committed
Repair boundary-case bug introduced by patch of two months ago that
fixed incorrect initial setting of StartUpID. The logic in XLogWrite()expects that Write->curridx is advanced to the next page as soon asLogwrtResult points to the end of the current page, but StartupXLOG()failed to make that happen when the old WAL ended exactly on a pageboundary. Per trouble report from Hannu Krosing.
1 parentc15b66e commit8cf63ba

File tree

1 file changed

+23
-3
lines changed
  • src/backend/access/transam

1 file changed

+23
-3
lines changed

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

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.117 2003/06/26 18:23:07 tgl Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.118 2003/07/17 16:45:04 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -2487,6 +2487,7 @@ StartupXLOG(void)
24872487
EndOfLog;
24882488
XLogRecord*record;
24892489
char*buffer;
2490+
uint32freespace;
24902491

24912492
/* Use malloc() to ensure record buffer is MAXALIGNED */
24922493
buffer= (char*)malloc(_INTL_MAXLOGRECSZ);
@@ -2697,8 +2698,6 @@ StartupXLOG(void)
26972698
memcpy((char*)Insert->currpage,readBuf,BLCKSZ);
26982699
Insert->currpos= (char*)Insert->currpage+
26992700
(EndOfLog.xrecoff+BLCKSZ-XLogCtl->xlblocks[0].xrecoff);
2700-
/* Make sure rest of page is zero */
2701-
MemSet(Insert->currpos,0,INSERT_FREESPACE(Insert));
27022701

27032702
LogwrtResult.Write=LogwrtResult.Flush=EndOfLog;
27042703

@@ -2709,6 +2708,27 @@ StartupXLOG(void)
27092708
XLogCtl->LogwrtRqst.Write=EndOfLog;
27102709
XLogCtl->LogwrtRqst.Flush=EndOfLog;
27112710

2711+
freespace=INSERT_FREESPACE(Insert);
2712+
if (freespace>0)
2713+
{
2714+
/* Make sure rest of page is zero */
2715+
MemSet(Insert->currpos,0,freespace);
2716+
XLogCtl->Write.curridx=0;
2717+
}
2718+
else
2719+
{
2720+
/*
2721+
* Whenever Write.LogwrtResult points to exactly the end of a page,
2722+
* Write.curridx must point to the *next* page (see XLogWrite()).
2723+
*
2724+
* Note: it might seem we should do AdvanceXLInsertBuffer() here,
2725+
* but we can't since we haven't yet determined the correct StartUpID
2726+
* to put into the new page's header. The first actual attempt to
2727+
* insert a log record will advance the insert state.
2728+
*/
2729+
XLogCtl->Write.curridx=NextBufIdx(0);
2730+
}
2731+
27122732
#ifdefNOT_USED
27132733
/* UNDO */
27142734
if (InRecovery)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp