1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-29 10:41:53 +03:00

Separate out bgwriter code into a logically separate module, rather

than being random pieces of other files.  Give bgwriter responsibility
for all checkpoint activity (other than a post-recovery checkpoint);
so this child process absorbs the functionality of the former transient
checkpoint and shutdown subprocesses.  While at it, create an actual
include file for postmaster.c, which for some reason never had its own
file before.
This commit is contained in:
Tom Lane
2004-05-29 22:48:23 +00:00
parent d531fd2cdc
commit 076a055acf
28 changed files with 1133 additions and 902 deletions

View File

@ -7,7 +7,7 @@
* 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.144 2004/05/28 05:12:42 tgl Exp $
* $PostgreSQL: pgsql/src/backend/access/transam/xlog.c,v 1.145 2004/05/29 22:48:18 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@ -27,10 +27,10 @@
#include "access/xlogutils.h"
#include "catalog/catversion.h"
#include "catalog/pg_control.h"
#include "postmaster/bgwriter.h"
#include "storage/bufpage.h"
#include "storage/fd.h"
#include "storage/lwlock.h"
#include "storage/pmsignal.h"
#include "storage/proc.h"
#include "storage/sinval.h"
#include "storage/spin.h"
@ -1206,9 +1206,9 @@ XLogWrite(XLogwrtRqst WriteRqst)
{
#ifdef WAL_DEBUG
if (XLOG_DEBUG)
elog(LOG, "time for a checkpoint, signaling postmaster");
elog(LOG, "time for a checkpoint, signaling bgwriter");
#endif
SendPostmasterSignal(PMSIGNAL_DO_CHECKPOINT);
RequestCheckpoint(false);
}
}
LWLockRelease(ControlFileLock);
@ -3087,11 +3087,6 @@ StartupXLOG(void)
RmgrTable[rmid].rm_cleanup();
}
/* suppress in-transaction check in CreateCheckPoint */
MyLastRecPtr.xrecoff = 0;
MyXactMadeXLogEntry = false;
MyXactMadeTempRelUpdate = false;
/*
* At this point, ThisStartUpID is the largest SUI that we could
* find evidence for in the WAL entries. But check it against
@ -3293,11 +3288,6 @@ ShutdownXLOG(int code, Datum arg)
ereport(LOG,
(errmsg("shutting down")));
/* suppress in-transaction check in CreateCheckPoint */
MyLastRecPtr.xrecoff = 0;
MyXactMadeXLogEntry = false;
MyXactMadeTempRelUpdate = false;
CritSectionCount++;
CreateCheckPoint(true, true);
ShutdownCLOG();
@ -3324,27 +3314,13 @@ CreateCheckPoint(bool shutdown, bool force)
uint32 _logId;
uint32 _logSeg;
if (MyXactMadeXLogEntry)
ereport(ERROR,
(errcode(ERRCODE_ACTIVE_SQL_TRANSACTION),
errmsg("checkpoint cannot be made inside transaction block")));
/*
* Acquire CheckpointLock to ensure only one checkpoint happens at a
* time.
*
* The CheckpointLock can be held for quite a while, which is not good
* because we won't respond to a cancel/die request while waiting for
* an LWLock. (But the alternative of using a regular lock won't work
* for background checkpoint processes, which are not regular
* backends.) So, rather than use a plain LWLockAcquire, use this
* kluge to allow an interrupt to be accepted while we are waiting:
* 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 time.)
*/
while (!LWLockConditionalAcquire(CheckpointLock, LW_EXCLUSIVE))
{
CHECK_FOR_INTERRUPTS();
pg_usleep(1000000L);
}
LWLockAcquire(CheckpointLock, LW_EXCLUSIVE);
/*
* Use a critical section to force system panic if we have trouble.