File tree Expand file tree Collapse file tree 2 files changed +23
-19
lines changed
src/backend/storage/buffer Expand file tree Collapse file tree 2 files changed +23
-19
lines changed Original file line number Diff line number Diff 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 */
16641665static void
16651666AtProcExit_Buffers (int code , Datum arg )
16661667{
1667- int i ;
1668-
16691668 AbortBufferIO ();
16701669 UnlockBuffers ();
16711670
1672- for (i = 0 ; i < NBuffers ; i ++ )
1671+ #ifdef USE_ASSERT_CHECKING
1672+ if (assert_enabled )
16731673 {
1674- if (PrivateRefCount [i ] != 0 )
1675- {
1676- volatile BufferDesc * buf = & (BufferDescriptors [i ]);
1674+ int i ;
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 ();
Original file line number Diff line number Diff 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 */
475476void
476477AtProcExit_LocalBuffers (void )
477478{
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
481490}
You can’t perform that action at this time.
0 commit comments