summaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlog.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2003-02-21 00:06:22 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2003-02-21 00:06:22 +0000
commit70508ba7aed76954b7e630a4952e1360c15db830 (patch)
tree5e688d748e5a183a1248153203ff8ededfd020a8 /src/backend/access/transam/xlog.c
parent4df0f1d26f62e835bb357fa7c2e3d5de5fcbf802 (diff)
downloadpostgresql-70508ba7aed76954b7e630a4952e1360c15db830.tar.gz
Make btree index structure adjustments and WAL logging changes needed to
support btree compaction, as per proposal of a few days ago. btree index pages no longer store parent links, instead they have a level indicator (counting up from zero for leaf pages). The FixBTree recovery logic is removed, and replaced by code that detects missing parent-level insertions during WAL replay. Also, generate appropriate WAL entries when updating btree metapage and when building a btree index from scratch. I believe btree indexes are now completely WAL-legal for the first time. initdb forced due to index and WAL changes.
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r--src/backend/access/transam/xlog.c58
1 files changed, 47 insertions, 11 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index c35762bba9..3b615f8229 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.111 2003/01/25 03:06:04 tgl Exp $
+ * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.112 2003/02/21 00:06:22 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -1203,16 +1203,6 @@ XLogFlush(XLogRecPtr record)
XLogRecPtr WriteRqstPtr;
XLogwrtRqst WriteRqst;
- if (XLOG_DEBUG)
- {
- elog(LOG, "XLogFlush%s%s: request %X/%X; write %X/%X; flush %X/%X",
- (IsBootstrapProcessingMode()) ? "(bootstrap)" : "",
- (InRedo) ? "(redo)" : "",
- record.xlogid, record.xrecoff,
- LogwrtResult.Write.xlogid, LogwrtResult.Write.xrecoff,
- LogwrtResult.Flush.xlogid, LogwrtResult.Flush.xrecoff);
- }
-
/* Disabled during REDO */
if (InRedo)
return;
@@ -1221,6 +1211,15 @@ XLogFlush(XLogRecPtr record)
if (XLByteLE(record, LogwrtResult.Flush))
return;
+ if (XLOG_DEBUG)
+ {
+ elog(LOG, "XLogFlush%s: request %X/%X; write %X/%X; flush %X/%X",
+ (IsBootstrapProcessingMode()) ? "(bootstrap)" : "",
+ record.xlogid, record.xrecoff,
+ LogwrtResult.Write.xlogid, LogwrtResult.Write.xrecoff,
+ LogwrtResult.Flush.xlogid, LogwrtResult.Flush.xrecoff);
+ }
+
START_CRIT_SECTION();
/*
@@ -2515,6 +2514,12 @@ StartupXLOG(void)
elog(LOG, "database system was interrupted at %s",
str_time(ControlFile->time));
+ /* This is just to allow attaching to startup process with a debugger */
+#ifdef XLOG_REPLAY_DELAY
+ if (XLOG_DEBUG && ControlFile->state != DB_SHUTDOWNED)
+ sleep(60);
+#endif
+
/*
* Get the last valid checkpoint record. If the latest one according
* to pg_control is broken, try the next-to-last one.
@@ -2578,14 +2583,23 @@ StartupXLOG(void)
/* REDO */
if (InRecovery)
{
+ int rmid;
+
elog(LOG, "database system was not properly shut down; "
"automatic recovery in progress");
ControlFile->state = DB_IN_RECOVERY;
ControlFile->time = time(NULL);
UpdateControlFile();
+ /* Start up the recovery environment */
XLogInitRelationCache();
+ for (rmid = 0; rmid <= RM_MAX_ID; rmid++)
+ {
+ if (RmgrTable[rmid].rm_startup != NULL)
+ RmgrTable[rmid].rm_startup();
+ }
+
/* Is REDO required ? */
if (XLByteLT(checkPoint.redo, RecPtr))
record = ReadRecord(&(checkPoint.redo), PANIC, buffer);
@@ -2737,7 +2751,25 @@ StartupXLOG(void)
if (InRecovery)
{
+ int rmid;
+
+ /*
+ * Allow resource managers to do any required cleanup.
+ */
+ for (rmid = 0; rmid <= RM_MAX_ID; rmid++)
+ {
+ if (RmgrTable[rmid].rm_cleanup != NULL)
+ RmgrTable[rmid].rm_cleanup();
+ }
+
+ /* suppress in-transaction check in CreateCheckPoint */
+ MyLastRecPtr.xrecoff = 0;
+ MyXactMadeXLogEntry = false;
+ MyXactMadeTempRelUpdate = false;
+
/*
+ * Perform a new checkpoint to update our recovery activity to disk.
+ *
* In case we had to use the secondary checkpoint, make sure that
* it will still be shown as the secondary checkpoint after this
* CreateCheckPoint operation; we don't want the broken primary
@@ -2745,6 +2777,10 @@ StartupXLOG(void)
*/
ControlFile->checkPoint = checkPointLoc;
CreateCheckPoint(true, true);
+
+ /*
+ * Close down recovery environment
+ */
XLogCloseRelationCache();
}