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

Commitc2281ac

Browse files
committed
Remove belt-and-suspenders guards against buffer pin leaks.
Forcibly releasing all leftover buffer pins should be unnecessary nowthat we have a robust ResourceOwner mechanism, and it significantlyincreases the cost of process shutdown. Instead, in an assert-enabledbuild, assert that no pins are held; in a non-assert-enabled build, donothing.
1 parent58dfb07 commitc2281ac

File tree

2 files changed

+23
-19
lines changed

2 files changed

+23
-19
lines changed

‎src/backend/storage/buffer/bufmgr.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1659,31 +1659,26 @@ InitBufferPoolBackend(void)
16591659
}
16601660

16611661
/*
1662-
* Ensure we have released all shared-buffer locks and pins during backend exit
1662+
* During backend exit, ensure that we released all shared-buffer locks and
1663+
* assert that we have no remaining pins.
16631664
*/
16641665
staticvoid
16651666
AtProcExit_Buffers(intcode,Datumarg)
16661667
{
1667-
inti;
1668-
16691668
AbortBufferIO();
16701669
UnlockBuffers();
16711670

1672-
for (i=0;i<NBuffers;i++)
1671+
#ifdefUSE_ASSERT_CHECKING
1672+
if (assert_enabled)
16731673
{
1674-
if (PrivateRefCount[i]!=0)
1675-
{
1676-
volatileBufferDesc*buf=&(BufferDescriptors[i]);
1674+
inti;
16771675

1678-
/*
1679-
* We don't worry about updating ResourceOwner; if we even got
1680-
* here, it suggests that ResourceOwners are messed up.
1681-
*/
1682-
PrivateRefCount[i]=1;/* make sure we release shared pin */
1683-
UnpinBuffer(buf, false);
1676+
for (i=0;i<NBuffers;i++)
1677+
{
16841678
Assert(PrivateRefCount[i]==0);
16851679
}
16861680
}
1681+
#endif
16871682

16881683
/* localbuf.c needs a chance too */
16891684
AtProcExit_LocalBuffers();

‎src/backend/storage/buffer/localbuf.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -468,14 +468,23 @@ AtEOXact_LocalBuffers(bool isCommit)
468468
/*
469469
* AtProcExit_LocalBuffers - ensure we have dropped pins during backend exit.
470470
*
471-
* This is just like AtProcExit_Buffers, but for local buffers. We have
472-
* to drop pins to ensure that any attempt to drop temp files doesn't
473-
* fail in DropRelFileNodeBuffers.
471+
* This is just like AtProcExit_Buffers, but for local buffers. We shouldn't
472+
* be holding any remaining pins; if we are, and assertions aren't enabled,
473+
* we'll fail later in DropRelFileNodeBuffers while trying to drop the temp
474+
* rels.
474475
*/
475476
void
476477
AtProcExit_LocalBuffers(void)
477478
{
478-
/* just zero the refcounts ... */
479-
if (LocalRefCount)
480-
MemSet(LocalRefCount,0,NLocBuffer*sizeof(*LocalRefCount));
479+
#ifdefUSE_ASSERT_CHECKING
480+
if (assert_enabled&&LocalRefCount)
481+
{
482+
inti;
483+
484+
for (i=0;i<NLocBuffer;i++)
485+
{
486+
Assert(LocalRefCount[i]==0);
487+
}
488+
}
489+
#endif
481490
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp