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

Commitbfa5f30

Browse files
committed
Awhile back I added some code to StartupCLOG() to forcibly zero out
the remainder of the current clog page during system startup. Whilethis was a good idea, it turns out the code fails if nextXid isexactly at a page boundary, because we won't have created the "current"clog page yet in that case. Since the page will be correctly zeroedwhen we execute the first transaction on it, the solution is just todo nothing when exactly at a page boundary. Per trouble report fromDave Hartwig.
1 parent766b0bb commitbfa5f30

File tree

1 file changed

+19
-13
lines changed
  • src/backend/access/transam

1 file changed

+19
-13
lines changed

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

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
* Portions Copyright (c) 1996-2004, PostgreSQL Global Development Group
2525
* Portions Copyright (c) 1994, Regents of the University of California
2626
*
27-
* $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.26 2004/08/30 19:00:42 tgl Exp $
27+
* $PostgreSQL: pgsql/src/backend/access/transam/clog.c,v 1.27 2004/12/22 18:45:49 tgl Exp $
2828
*
2929
*-------------------------------------------------------------------------
3030
*/
@@ -212,10 +212,6 @@ StartupCLOG(void)
212212
{
213213
TransactionIdxid=ShmemVariableCache->nextXid;
214214
intpageno=TransactionIdToPage(xid);
215-
intbyteno=TransactionIdToByte(xid);
216-
intbshift=TransactionIdToBIndex(xid)*CLOG_BITS_PER_XACT;
217-
intslotno;
218-
char*byteptr;
219215

220216
LWLockAcquire(CLogControlLock,LW_EXCLUSIVE);
221217

@@ -232,17 +228,27 @@ StartupCLOG(void)
232228
* marked by the previous database lifecycle (since subtransaction
233229
* commit writes clog but makes no WAL entry). Let's just be safe.
234230
* (We need not worry about pages beyond the current one, since those
235-
* will be zeroed when first used.)
231+
* will be zeroed when first used. For the same reason, there is no
232+
* need to do anything when nextXid is exactly at a page boundary; and
233+
* it's likely that the "current" page doesn't exist yet in that case.)
236234
*/
237-
slotno=SimpleLruReadPage(ClogCtl,pageno,xid);
238-
byteptr=ClogCtl->shared->page_buffer[slotno]+byteno;
235+
if (TransactionIdToPgIndex(xid)!=0)
236+
{
237+
intbyteno=TransactionIdToByte(xid);
238+
intbshift=TransactionIdToBIndex(xid)*CLOG_BITS_PER_XACT;
239+
intslotno;
240+
char*byteptr;
239241

240-
/* Zero so-far-unused positions in the current byte */
241-
*byteptr &= (1 <<bshift)-1;
242-
/* Zero the rest of the page */
243-
MemSet(byteptr+1,0,BLCKSZ-byteno-1);
242+
slotno=SimpleLruReadPage(ClogCtl,pageno,xid);
243+
byteptr=ClogCtl->shared->page_buffer[slotno]+byteno;
244244

245-
ClogCtl->shared->page_status[slotno]=SLRU_PAGE_DIRTY;
245+
/* Zero so-far-unused positions in the current byte */
246+
*byteptr &= (1 <<bshift)-1;
247+
/* Zero the rest of the page */
248+
MemSet(byteptr+1,0,BLCKSZ-byteno-1);
249+
250+
ClogCtl->shared->page_status[slotno]=SLRU_PAGE_DIRTY;
251+
}
246252

247253
LWLockRelease(CLogControlLock);
248254
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp