1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-03 20:02:46 +03:00

Remove ShutdownBufferPoolAccess exit callback, and do the work in

ProcKill instead, where we still have a PGPROC with which to wait on
LWLocks.  This fixes 'can't wait without a PROC structure' failures
occasionally seen during backend shutdown (I'm surprised they weren't
more frequent, actually).  Add an Assert() to LWLockAcquire to help
catch any similar mistakes in future.  Fix failure to update MyProcPid
for standalone backends and pgstat processes.
This commit is contained in:
Tom Lane
2002-09-25 20:31:40 +00:00
parent 691aefcf42
commit 8a6fab412e
6 changed files with 43 additions and 34 deletions

View File

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.52 2002/09/04 20:31:25 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.53 2002/09/25 20:31:40 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -35,8 +35,6 @@
#include "utils/memutils.h"
static void ShutdownBufferPoolAccess(void);
/*
* if BMTRACE is defined, we trace the last 200 buffer allocations and
* deallocations in a circular buffer in shared memory.
@ -219,6 +217,10 @@ InitBufferPool(void)
* This is called during backend startup (whether standalone or under the
* postmaster). It sets up for this backend's access to the already-existing
* buffer pool.
*
* NB: this is called before InitProcess(), so we do not have a PGPROC and
* cannot do LWLockAcquire; hence we can't actually access the bufmgr's
* shared memory yet. We are only initializing local data here.
*/
void
InitBufferPoolAccess(void)
@ -238,27 +240,6 @@ InitBufferPoolAccess(void)
*/
for (i = 0; i < NBuffers; i++)
BufferBlockPointers[i] = (Block) MAKE_PTR(BufferDescriptors[i].data);
/*
* Now that buffer access is initialized, set up a callback to shut it
* down again at backend exit.
*/
on_shmem_exit(ShutdownBufferPoolAccess, 0);
}
/*
* Shut down buffer manager at backend exit.
*
* This is needed mainly to ensure that we don't leave any buffer reference
* counts set during an error exit.
*/
static void
ShutdownBufferPoolAccess(void)
{
/* Release any buffer context locks we are holding */
UnlockBuffers();
/* Release any buffer reference counts we are holding */
AtEOXact_Buffers(false);
}
/* -----------------------------------------------------