File tree 2 files changed +23
-19
lines changed
src/backend/storage/buffer
2 files changed +23
-19
lines changed Original file line number Diff line number Diff line change @@ -1659,31 +1659,26 @@ InitBufferPoolBackend(void)
1659
1659
}
1660
1660
1661
1661
/*
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.
1663
1664
*/
1664
1665
static void
1665
1666
AtProcExit_Buffers (int code , Datum arg )
1666
1667
{
1667
- int i ;
1668
-
1669
1668
AbortBufferIO ();
1670
1669
UnlockBuffers ();
1671
1670
1672
- for (i = 0 ; i < NBuffers ; i ++ )
1671
+ #ifdef USE_ASSERT_CHECKING
1672
+ if (assert_enabled )
1673
1673
{
1674
- if (PrivateRefCount [i ] != 0 )
1675
- {
1676
- volatile BufferDesc * buf = & (BufferDescriptors [i ]);
1674
+ int i ;
1677
1675
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
+ {
1684
1678
Assert (PrivateRefCount [i ] == 0 );
1685
1679
}
1686
1680
}
1681
+ #endif
1687
1682
1688
1683
/* localbuf.c needs a chance too */
1689
1684
AtProcExit_LocalBuffers ();
Original file line number Diff line number Diff line change @@ -468,14 +468,23 @@ AtEOXact_LocalBuffers(bool isCommit)
468
468
/*
469
469
* AtProcExit_LocalBuffers - ensure we have dropped pins during backend exit.
470
470
*
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.
474
475
*/
475
476
void
476
477
AtProcExit_LocalBuffers (void )
477
478
{
478
- /* just zero the refcounts ... */
479
- if (LocalRefCount )
480
- MemSet (LocalRefCount , 0 , NLocBuffer * sizeof (* LocalRefCount ));
479
+ #ifdef USE_ASSERT_CHECKING
480
+ if (assert_enabled && LocalRefCount )
481
+ {
482
+ int i ;
483
+
484
+ for (i = 0 ; i < NLocBuffer ; i ++ )
485
+ {
486
+ Assert (LocalRefCount [i ] == 0 );
487
+ }
488
+ }
489
+ #endif
481
490
}
You can’t perform that action at this time.
0 commit comments