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

Commit5787c67

Browse files
Skip extraneous locking in XLogCheckBuffer().
Heikki reported comment was wrong, so fixedcode to match the comment: we only need totake additional locking precautions when wehave a shared lock on the buffer.
1 parent47c4333 commit5787c67

File tree

1 file changed

+16
-11
lines changed
  • src/backend/access/transam

1 file changed

+16
-11
lines changed

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

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -646,7 +646,7 @@ static void CreateEndOfRecoveryRecord(void);
646646
staticvoidCheckPointGuts(XLogRecPtrcheckPointRedo,intflags);
647647
staticvoidKeepLogSeg(XLogRecPtrrecptr,XLogSegNo*logSegNo);
648648

649-
staticboolXLogCheckBuffer(XLogRecData*rdata,booldoPageWrites,
649+
staticboolXLogCheckBuffer(XLogRecData*rdata,boolholdsExclusiveLock,
650650
XLogRecPtr*lsn,BkpBlock*bkpb);
651651
staticBufferRestoreBackupBlockContents(XLogRecPtrlsn,BkpBlockbkpb,
652652
char*blk,boolget_cleanup_lock,boolkeep_buffer);
@@ -822,7 +822,7 @@ begin:;
822822
{
823823
/* OK, put it in this slot */
824824
dtbuf[i]=rdt->buffer;
825-
if (XLogCheckBuffer(rdt,doPageWrites,
825+
if (doPageWrites&&XLogCheckBuffer(rdt,true,
826826
&(dtbuf_lsn[i]),&(dtbuf_xlg[i])))
827827
{
828828
dtbuf_bkp[i]= true;
@@ -1243,23 +1243,25 @@ begin:;
12431243
* save the buffer's LSN at *lsn.
12441244
*/
12451245
staticbool
1246-
XLogCheckBuffer(XLogRecData*rdata,booldoPageWrites,
1246+
XLogCheckBuffer(XLogRecData*rdata,boolholdsExclusiveLock,
12471247
XLogRecPtr*lsn,BkpBlock*bkpb)
12481248
{
12491249
Pagepage;
12501250

12511251
page=BufferGetPage(rdata->buffer);
12521252

12531253
/*
1254-
*XXXWe assume page LSN is first data on *every* page that can be passed
1255-
* to XLogInsert, whether itotherwisehas the standard page layout or
1256-
*not. Wedon't need the buffer header lock for PageGetLSNbecause we
1257-
*have exclusive lock on the page and/or the relation.
1254+
* We assume page LSN is first data on *every* page that can be passed
1255+
* to XLogInsert, whether it has the standard page layout or not. We
1256+
* don't needto takethe buffer header lock for PageGetLSNif we hold
1257+
*an exclusive lock on the page and/or the relation.
12581258
*/
1259-
*lsn=BufferGetLSNAtomic(rdata->buffer);
1259+
if (holdsExclusiveLock)
1260+
*lsn=PageGetLSN(page);
1261+
else
1262+
*lsn=BufferGetLSNAtomic(rdata->buffer);
12601263

1261-
if (doPageWrites&&
1262-
*lsn <=RedoRecPtr)
1264+
if (*lsn <=RedoRecPtr)
12631265
{
12641266
/*
12651267
* The page needs to be backed up, so set up *bkpb
@@ -7683,7 +7685,10 @@ XLogSaveBufferForHint(Buffer buffer)
76837685
rdata[0].buffer=buffer;
76847686
rdata[0].buffer_std= true;
76857687

7686-
if (XLogCheckBuffer(rdata, true,&lsn,&bkpb))
7688+
/*
7689+
* Check buffer while not holding an exclusive lock.
7690+
*/
7691+
if (XLogCheckBuffer(rdata, false,&lsn,&bkpb))
76877692
{
76887693
charcopied_buffer[BLCKSZ];
76897694
char*origdata= (char*)BufferGetBlock(buffer);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp