aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlog.c
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2014-11-28 09:23:41 +0200
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2014-11-28 09:31:53 +0200
commitafeacd274830d1e3d15ffc4e4d4b08a887f76abb (patch)
tree056d8a799e7ad9f5ed9fb32b75a00dddb496ca79 /src/backend/access/transam/xlog.c
parenta5eb85eb6266c99f79144201f1162e5106969575 (diff)
downloadpostgresql-afeacd274830d1e3d15ffc4e4d4b08a887f76abb.tar.gz
postgresql-afeacd274830d1e3d15ffc4e4d4b08a887f76abb.zip
Fix assertion failure at end of PITR.
InitXLogInsert() cannot be called in a critical section, because it allocates memory. But CreateCheckPoint() did that, when called for the end-of-recovery checkpoint by the startup process. In the passing, fix the scratch space allocation in InitXLogInsert to go to the right memory context. Also update the comment at InitXLOGAccess, which hasn't been totally accurate since hot standby was introduced (in a hot standby backend, InitXLOGAccess isn't called at backend startup). Reported by Michael Paquier
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r--src/backend/access/transam/xlog.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 0f661f5010c..a2ad5ebfe82 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7254,10 +7254,9 @@ ReadCheckpointRecord(XLogReaderState *xlogreader, XLogRecPtr RecPtr,
}
/*
- * 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 ThisTimeLineID and
- * RedoRecPtr.
+ * This must be called in a backend process before creating WAL records
+ * (except in a standalone backend, which does StartupXLOG instead). We need
+ * to initialize the local copies of ThisTimeLineID and RedoRecPtr.
*
* Note: before Postgres 8.0, we went to some effort to keep the postmaster
* process's copies of ThisTimeLineID and RedoRecPtr valid too. This was
@@ -7595,6 +7594,16 @@ CreateCheckPoint(int flags)
elog(ERROR, "can't create a checkpoint during recovery");
/*
+ * Initialize InitXLogInsert working areas before entering the critical
+ * section. Normally, this is done by the first call to
+ * RecoveryInProgress() or LocalSetXLogInsertAllowed(), but when creating
+ * an end-of-recovery checkpoint, the LocalSetXLogInsertAllowed call is
+ * done below in a critical section, and InitXLogInsert cannot be called
+ * in a critical section.
+ */
+ InitXLogInsert();
+
+ /*
* Acquire CheckpointLock to ensure only one checkpoint happens at a time.
* (This is just pro forma, since in the present system structure there is
* only one process that is allowed to issue checkpoints at any given