*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.167 2004/05/20 15:07:30 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/heap/heapam.c,v 1.168 2004/05/27 17:12:37 tgl Exp $
*
*
* INTERFACE ROUTINES
* XLOG stuff: no logging is required as long as we have no
* savepoints. For savepoints private log could be used...
*/
- ((PageHeader) BufferGetPage(*buffer))->pd_sui = ThisStartUpID;
+ PageSetSUI(BufferGetPage(*buffer), ThisStartUpID);
/* store transaction information of xact marking the tuple */
tuple->t_data->t_infomask &= ~(HEAP_XMAX_COMMITTED |
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.142 2004/05/21 16:08:46 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.143 2004/05/27 17:12:42 tgl Exp $
*
*-------------------------------------------------------------------------
*/
* XLogCtl->Insert.RedoRecPtr, whenever we can safely do so (ie, when we
* hold the Insert lock). See XLogInsert for details. We are also allowed
* to update from XLogCtl->Insert.RedoRecPtr if we hold the info_lck;
- * see GetRedoRecPtr.
+ * see GetRedoRecPtr. A freshly spawned backend obtains the value during
+ * InitXLOGAccess.
*/
-NON_EXEC_STATIC XLogRecPtr RedoRecPtr;
+static XLogRecPtr RedoRecPtr;
/*----------
* Shared-memory data structures for XLOG control
uint32 XLogCacheBlck; /* highest allocated xlog buffer index */
StartUpID ThisStartUpID;
- /* This value is not protected by *any* lock... */
- /* see SetSavedRedoRecPtr/GetSavedRedoRecPtr */
- XLogRecPtr SavedRedoRecPtr;
-
slock_t info_lck; /* locks shared LogwrtRqst/LogwrtResult */
} XLogCtlData;
else
ThisStartUpID = checkPoint.ThisStartUpID;
- RedoRecPtr = XLogCtl->Insert.RedoRecPtr =
- XLogCtl->SavedRedoRecPtr = checkPoint.redo;
+ RedoRecPtr = XLogCtl->Insert.RedoRecPtr = checkPoint.redo;
if (XLByteLT(RecPtr, checkPoint.redo))
ereport(PANIC,
}
/*
- * Postmaster uses this to initialize ThisStartUpID & RedoRecPtr from
- * XLogCtlData located in shmem after successful startup.
+ * This must be called during startup of a backend process, except that
+ * it need not be called in a standalone backend (which does StartupXLOG
+ * instead). We need to initialize the local copies of ThisStartUpID and
+ * RedoRecPtr.
+ *
+ * Note: before Postgres 7.5, we went to some effort to keep the postmaster
+ * process's copies of ThisStartUpID and RedoRecPtr valid too. This was
+ * unnecessary however, since the postmaster itself never touches XLOG anyway.
*/
void
-SetThisStartUpID(void)
+InitXLOGAccess(void)
{
+ /* ThisStartUpID doesn't change so we need no lock to copy it */
ThisStartUpID = XLogCtl->ThisStartUpID;
- RedoRecPtr = XLogCtl->SavedRedoRecPtr;
-}
-
-/*
- * CheckPoint process called by postmaster saves copy of new RedoRecPtr
- * in shmem (using SetSavedRedoRecPtr). When checkpointer completes,
- * postmaster calls GetSavedRedoRecPtr to update its own copy of RedoRecPtr,
- * so that subsequently-spawned backends will start out with a reasonably
- * up-to-date local RedoRecPtr. Since these operations are not protected by
- * any lock and copying an XLogRecPtr isn't atomic, it's unsafe to use either
- * of these routines at other times!
- */
-void
-SetSavedRedoRecPtr(void)
-{
- XLogCtl->SavedRedoRecPtr = RedoRecPtr;
-}
-
-void
-GetSavedRedoRecPtr(void)
-{
- RedoRecPtr = XLogCtl->SavedRedoRecPtr;
+ /* Use GetRedoRecPtr to copy the RedoRecPtr safely */
+ (void) GetRedoRecPtr();
}
/*
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.179 2004/05/21 05:07:56 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/bootstrap/bootstrap.c,v 1.180 2004/05/27 17:12:49 tgl Exp $
*
*-------------------------------------------------------------------------
*/
break;
case BS_XLOG_CHECKPOINT:
+ InitXLOGAccess();
CreateCheckPoint(false, false);
- SetSavedRedoRecPtr(); /* pass redo ptr back to
- * postmaster */
proc_exit(0); /* done */
case BS_XLOG_BGWRITER:
+ InitXLOGAccess();
BufferBackgroundWriter();
proc_exit(0); /* done */
proc_exit(0); /* done */
case BS_XLOG_SHUTDOWN:
+ InitXLOGAccess();
ShutdownXLOG(0, 0);
DumpFreeSpaceMap(0, 0);
proc_exit(0); /* done */
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.396 2004/05/27 15:07:41 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/postmaster/postmaster.c,v 1.397 2004/05/27 17:12:52 tgl Exp $
*
* NOTES
*
* trouble...
*/
win32_RemoveChild(pid);
-#endif
-#endif
+#endif /* WIN32 */
+#endif /* HAVE_WAITPID */
/*
* Check if this child was the statistics collector. If so, try to
StartupPID = 0;
/*
- * Startup succeeded - remember its ID and RedoRecPtr.
- *
- * NB: this MUST happen before we fork a checkpoint or shutdown
- * subprocess, else they will have wrong local ThisStartUpId.
+ * Startup succeeded - we are done with system startup or recovery.
*/
- SetThisStartUpID();
-
- FatalError = false; /* done with recovery */
+ FatalError = false;
/*
* Arrange for first checkpoint to occur after standard delay.
if (!FatalError)
{
checkpointed = time(NULL);
- /* Update RedoRecPtr for future child backends */
- GetSavedRedoRecPtr();
}
}
else if (pid == BgWriterPID)
* functions
*/
#include "storage/spin.h"
-extern XLogRecPtr RedoRecPtr;
extern XLogwrtResult LogwrtResult;
extern slock_t *ShmemLock;
extern slock_t *ShmemIndexLock;
}
write_var(MyCancelKey, fp);
- write_var(RedoRecPtr, fp);
write_var(LogwrtResult, fp);
write_var(UsedShmemSegID, fp);
}
read_var(MyCancelKey, fp);
- read_var(RedoRecPtr, fp);
read_var(LogwrtResult, fp);
read_var(UsedShmemSegID, fp);
*
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.131 2003/12/12 18:45:09 petere Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/init/postinit.c,v 1.132 2004/05/27 17:12:54 tgl Exp $
*
*
*-------------------------------------------------------------------------
*/
AmiTransactionOverride(bootstrap);
+ /*
+ * Initialize local process's access to XLOG. In bootstrap case
+ * we may skip this since StartupXLOG() was run instead.
+ */
+ if (!bootstrap)
+ InitXLOGAccess();
+
/*
* Initialize the relation descriptor cache. This must create at
* least the minimum set of "nailed-in" cache entries. No catalog
* Portions Copyright (c) 1996-2003, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.49 2004/02/11 22:55:25 tgl Exp $
+ * $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.50 2004/05/27 17:12:57 tgl Exp $
*/
#ifndef XLOG_H
#define XLOG_H
extern void BootStrapXLOG(void);
extern void StartupXLOG(void);
extern void ShutdownXLOG(int code, Datum arg);
+extern void InitXLOGAccess(void);
extern void CreateCheckPoint(bool shutdown, bool force);
-extern void SetThisStartUpID(void);
extern void XLogPutNextOid(Oid nextOid);
-extern void SetSavedRedoRecPtr(void);
-extern void GetSavedRedoRecPtr(void);
extern XLogRecPtr GetRedoRecPtr(void);
/* in storage/ipc/sinval.c, but don't want to declare in sinval.h because