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

Commit38a2379

Browse files
committed
Change some bogus PageGetLSN calls to BufferGetLSNAtomic
As src/backend/access/transam/README says, PageGetLSN may only be calledby processes holding either exclusive lock on buffer, or a shared lockon buffer plus buffer header lock. Therefore any place that only holdsa shared buffer lock must use BufferGetLSNAtomic instead of PageGetLSN,which internally obtains buffer header lock prior to reading the LSN.A few callsites failed to comply with this rule. This was detected byrunning all tests under a new (not committed) assertion that verifiesPageGetLSN locking contract. All but one of the callsites that failedthe assertion are fixed by this patch. Remaining callsites wereinspected manually and determined not to need any change.The exception (unfixed callsite) is in TestForOldSnapshot, which onlyhas a Page argument, making it impossible to access the correspondingBuffer from it. Fixing that seems a much larger patch that will have tobe done separately; and that's just as well, since it was onlyintroduced in 9.6 and other bugs are much older.Some of these bugs are ancient; backpatch all the way back to 9.3.Authors: Jacob Champion, Asim Praveen, Ashwin AgrawalReviewed-by: Michaël PaquierDiscussion:https://postgr.es/m/CABAq_6GXgQDVu3u12mK9O5Xt5abBZWQ0V40LZCE+oUf95XyNFg@mail.gmail.com
1 parent6c31ac1 commit38a2379

File tree

4 files changed

+6
-5
lines changed

4 files changed

+6
-5
lines changed

‎src/backend/access/gist/gist.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,8 @@ gistdoinsert(Relation r, IndexTuple itup, Size freespace, GISTSTATE *giststate)
566566
}
567567

568568
stack->page= (Page)BufferGetPage(stack->buffer);
569-
stack->lsn=PageGetLSN(stack->page);
569+
stack->lsn=xlocked ?
570+
PageGetLSN(stack->page) :BufferGetLSNAtomic(stack->buffer);
570571
Assert(!RelationNeedsWAL(state.r)|| !XLogRecPtrIsInvalid(stack->lsn));
571572

572573
/*
@@ -816,7 +817,7 @@ gistFindPath(Relation r, BlockNumber child, OffsetNumber *downlinkoffnum)
816817
break;
817818
}
818819

819-
top->lsn=PageGetLSN(page);
820+
top->lsn=BufferGetLSNAtomic(buffer);
820821

821822
/*
822823
* If F_FOLLOW_RIGHT is set, the page to the right doesn't have a

‎src/backend/access/gist/gistvacuum.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ gistbulkdelete(PG_FUNCTION_ARGS)
257257

258258
ptr= (GistBDItem*)palloc(sizeof(GistBDItem));
259259
ptr->blkno=ItemPointerGetBlockNumber(&(idxtuple->t_tid));
260-
ptr->parentlsn=PageGetLSN(page);
260+
ptr->parentlsn=BufferGetLSNAtomic(buffer);
261261
ptr->next=stack->next;
262262
stack->next=ptr;
263263

‎src/backend/access/nbtree/nbtsearch.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1157,7 +1157,7 @@ _bt_readpage(IndexScanDesc scan, ScanDirection dir, OffsetNumber offnum)
11571157
* safe to apply LP_DEAD hints to the page later. This allows us to drop
11581158
* the pin for MVCC scans, which allows vacuum to avoid blocking.
11591159
*/
1160-
so->currPos.lsn=PageGetLSN(page);
1160+
so->currPos.lsn=BufferGetLSNAtomic(so->currPos.buf);
11611161

11621162
/*
11631163
* we must save the page's right-link while scanning it; this tells us

‎src/backend/access/nbtree/nbtutils.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1770,7 +1770,7 @@ _bt_killitems(IndexScanDesc scan)
17701770
return;
17711771

17721772
page=BufferGetPage(buf);
1773-
if (PageGetLSN(page)==so->currPos.lsn)
1773+
if (BufferGetLSNAtomic(buf)==so->currPos.lsn)
17741774
so->currPos.buf=buf;
17751775
else
17761776
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp