Back-patch fix for 'can't wait without a PROC structure' failures:
authorTom Lane <[email protected]>
Mon, 30 Sep 2002 20:18:59 +0000 (20:18 +0000)
committerTom Lane <[email protected]>
Mon, 30 Sep 2002 20:18:59 +0000 (20:18 +0000)
remove separate ShutdownBufferPoolAccess exit callback, and do the
work in ProcKill instead, before we delete MyProc.

src/backend/bootstrap/bootstrap.c
src/backend/storage/buffer/buf_init.c
src/backend/storage/lmgr/lwlock.c
src/backend/storage/lmgr/proc.c

index f3b6f1f9558b09df3491787e80d37f5ba2661e0a..420f19499bb92182f2a7cd9f65e76f96fd0cf6ad 100644 (file)
@@ -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 */
index 37570e6b118bc6e6555e7d485797bfae36198c68..eca2548ab56cb59cfc61167e8df24f58685e1fde 100644 (file)
@@ -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);
 }
 
 /* -----------------------------------------------------
index 4f82016c59a5d6031aa09090befd9149996582e3..c3e361c1d1b5d6422ad8ec8e0558c2ae92990699 100644 (file)
@@ -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
index b1be68a881f57ffda6a7548d78e94684354379e2..7fcd7325f90ded8886410b7e4ed9c31cf42db9f7 100644 (file)
@@ -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 */