Back-patch fix for 'can't wait without a PROC structure' failures:

remove separate ShutdownBufferPoolAccess exit callback, and do the
work in ProcKill instead, before we delete MyProc.
REL7_2_STABLE
Tom Lane 24 years ago
parent c80d09f123
commit c9e3806e57
  1. 7
      src/backend/bootstrap/bootstrap.c
  2. 25
      src/backend/storage/buffer/buf_init.c
  3. 9
      src/backend/storage/lmgr/lwlock.c
  4. 10
      src/backend/storage/lmgr/proc.c

@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.120.2.2 2002/09/30 19:55:08 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.120.2.3 2002/09/30 20:18:59 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -359,6 +359,9 @@ BootstrapMain(int argc, char *argv[])
BaseInit();
if (IsUnderPostmaster)
InitDummyProcess(); /* needed to get LWLocks */
/*
* XLOG operations
*/
@ -376,8 +379,6 @@ BootstrapMain(int argc, char *argv[])
break;
case BS_XLOG_CHECKPOINT:
if (IsUnderPostmaster)
InitDummyProcess(); /* needed to get LWLocks */
CreateDummyCaches();
CreateCheckPoint(false, false);
SetSavedRedoRecPtr(); /* pass redo ptr back to postmaster */

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.47 2001/11/05 17:46:27 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.47.2.1 2002/09/30 20:18:59 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -36,8 +36,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.
@ -244,27 +242,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 */
ResetBufferPool(false);
}
/* -----------------------------------------------------

@ -15,7 +15,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lwlock.c,v 1.8 2002/01/07 16:33:00 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lwlock.c,v 1.8.2.1 2002/09/30 20:18:59 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -204,6 +204,13 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode)
PRINT_LWDEBUG("LWLockAcquire", lockid, lock);
/*
* We can't wait if we haven't got a PROC. This should only occur
* during bootstrap or shared memory initialization. Put an Assert
* here to catch unsafe coding practices.
*/
Assert(!(proc == NULL && IsUnderPostmaster));
/*
* Lock out cancel/die interrupts until we exit the code section
* protected by the LWLock. This ensures that interrupts will not

@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.117 2001/12/28 18:16:43 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.117.2.1 2002/09/30 20:18:59 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -449,6 +449,10 @@ ProcKill(void)
/* Abort any buffer I/O in progress */
AbortBufferIO();
/* Release any buffer context locks we are holding */
UnlockBuffers();
/* Release any buffer reference counts we are holding */
ResetBufferPool(false);
/* Get off any wait queue I might be on */
LockWaitCancel();
@ -492,6 +496,10 @@ DummyProcKill(void)
/* Abort any buffer I/O in progress */
AbortBufferIO();
/* Release any buffer context locks we are holding */
UnlockBuffers();
/* Release any buffer reference counts we are holding */
ResetBufferPool(false);
/* I can't be on regular lock queues, so needn't check */

Loading…
Cancel
Save