]> granicus.if.org Git - postgresql/commitdiff
Fix checkpointer crash in EXEC_BACKEND builds.
authorRobert Haas <rhaas@postgresql.org>
Thu, 24 Jul 2014 13:04:59 +0000 (09:04 -0400)
committerRobert Haas <rhaas@postgresql.org>
Thu, 24 Jul 2014 13:12:38 +0000 (09:12 -0400)
Nothing in the checkpointer calls InitXLOGAccess(), so WALInsertLocks
never got initialized there.  Without EXEC_BACKEND, it works anyway
because the correct value is inherited from the postmaster, but
with EXEC_BACKEND we've got a problem.  The problem appears to have
been introduced by commit 68a2e52bbaf98f136a96b3a0d734ca52ca440a95.

To fix, move the relevant initialization steps from InitXLOGAccess()
to XLOGShmemInit(), making this more parallel to what we do
elsewhere.

Amit Kapila

src/backend/access/transam/xlog.c

index e4f9595ee5fef92981e771c8c10b7dec537542cb..93f3ca2b2b7fc90336189692741d1d0754092c0e 100644 (file)
@@ -4841,6 +4841,11 @@ XLOGShmemInit(void)
        {
                /* both should be present or neither */
                Assert(foundCFile && foundXLog);
+
+               /* Initialize local copy of WALInsertLocks and register the tranche */
+               WALInsertLocks = XLogCtl->Insert.WALInsertLocks;
+               LWLockRegisterTranche(XLogCtl->Insert.WALInsertLockTrancheId,
+                                                         &XLogCtl->Insert.WALInsertLockTranche);
                return;
        }
        memset(XLogCtl, 0, sizeof(XLogCtlData));
@@ -7619,11 +7624,6 @@ InitXLOGAccess(void)
        ThisTimeLineID = XLogCtl->ThisTimeLineID;
        Assert(ThisTimeLineID != 0 || IsBootstrapProcessingMode());
 
-       /* Initialize our copy of WALInsertLocks and register the tranche */
-       WALInsertLocks = XLogCtl->Insert.WALInsertLocks;
-       LWLockRegisterTranche(XLogCtl->Insert.WALInsertLockTrancheId,
-                                                 &XLogCtl->Insert.WALInsertLockTranche);
-
        /* Use GetRedoRecPtr to copy the RedoRecPtr safely */
        (void) GetRedoRecPtr();
 }