X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=src%2Finclude%2Faccess%2Fxlog.h;h=ea156d38345f5637a3eea892f43c4374117fc5ed;hb=85178327350e741a281a9a44283c7bf320950607;hp=f3db21ca43295596d78d28ff7fea0824ca257ef3;hpb=21d6a6a12850724b53ebc240080a90597b3b2580;p=pg-rex%2Fsyncrep.git diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index f3db21ca43..ea156d3834 100644 --- a/src/include/access/xlog.h +++ b/src/include/access/xlog.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.107 2010/04/18 18:06:07 sriggs Exp $ + * $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.117 2010/09/15 10:35:05 heikki Exp $ */ #ifndef XLOG_H #define XLOG_H @@ -135,22 +135,25 @@ typedef struct XLogRecData extern PGDLLIMPORT TimeLineID ThisTimeLineID; /* current TLI */ /* - * Prior to 8.4, all activity during recovery was carried out by Startup + * Prior to 8.4, all activity during recovery was carried out by the startup * process. This local variable continues to be used in many parts of the - * code to indicate actions taken by RecoveryManagers. Other processes who - * potentially perform work during recovery should check RecoveryInProgress() - * see XLogCtl notes in xlog.c + * code to indicate actions taken by RecoveryManagers. Other processes that + * potentially perform work during recovery should check RecoveryInProgress(). + * See XLogCtl notes in xlog.c. */ extern bool InRecovery; /* * Like InRecovery, standbyState is only valid in the startup process. + * In all other processes it will have the value STANDBY_DISABLED (so + * InHotStandby will read as FALSE). * * In DISABLED state, we're performing crash recovery or hot standby was - * disabled in recovery.conf. + * disabled in postgresql.conf. * - * In INITIALIZED state, we haven't yet received a RUNNING_XACTS or shutdown - * checkpoint record to initialize our master transaction tracking system. + * In INITIALIZED state, we've run InitRecoveryTransactionEnvironment, but + * we haven't yet processed a RUNNING_XACTS or shutdown-checkpoint WAL record + * to initialize our master-transaction tracking system. * * When the transaction tracking is initialized, we enter the SNAPSHOT_PENDING * state. The tracked information might still be incomplete, so we can't allow @@ -168,6 +171,7 @@ typedef enum STANDBY_SNAPSHOT_PENDING, STANDBY_SNAPSHOT_READY } HotStandbyState; + extern HotStandbyState standbyState; #define InHotStandby (standbyState >= STANDBY_SNAPSHOT_PENDING) @@ -187,32 +191,34 @@ extern XLogRecPtr XactLastRecEnd; /* these variables are GUC parameters related to XLOG */ extern int CheckPointSegments; -extern int StandbySegments; +extern int wal_keep_segments; extern int XLOGbuffers; +extern int XLogArchiveTimeout; extern bool XLogArchiveMode; extern char *XLogArchiveCommand; -extern int XLogArchiveTimeout; +extern bool EnableHotStandby; extern bool log_checkpoints; -extern bool XLogRequestRecoveryConnections; -extern int MaxStandbyDelay; -#define XLogArchivingActive() (XLogArchiveMode) -#define XLogArchiveCommandSet() (XLogArchiveCommand[0] != '\0') +/* WAL levels */ +typedef enum WalLevel +{ + WAL_LEVEL_MINIMAL = 0, + WAL_LEVEL_ARCHIVE, + WAL_LEVEL_HOT_STANDBY +} WalLevel; +extern int wal_level; -/* - * This is in walsender.c, but declared here so that we don't need to include - * walsender.h in all files that check XLogIsNeeded() - */ -extern int max_wal_senders; +#define XLogArchivingActive() (XLogArchiveMode && wal_level >= WAL_LEVEL_ARCHIVE) +#define XLogArchiveCommandSet() (XLogArchiveCommand[0] != '\0') /* - * Is WAL-logging necessary? We need to log an XLOG record iff either - * WAL archiving is enabled or XLOG streaming is allowed. + * Is WAL-logging necessary for archival or log-shipping, or can we skip + * WAL-logging if we fsync() the data before committing instead? */ -#define XLogIsNeeded() (XLogArchivingActive() || (max_wal_senders > 0)) +#define XLogIsNeeded() (wal_level >= WAL_LEVEL_ARCHIVE) /* Do we need to WAL-log information required only for Hot Standby? */ -#define XLogStandbyInfoActive() (XLogRequestRecoveryConnections && XLogIsNeeded()) +#define XLogStandbyInfoActive() (wal_level >= WAL_LEVEL_HOT_STANDBY) #ifdef WAL_DEBUG extern bool XLOG_DEBUG; @@ -255,10 +261,6 @@ typedef struct CheckpointStatsData extern CheckpointStatsData CheckpointStats; -/* Read from recovery.conf, in startup process */ -extern char *TriggerFile; - - extern XLogRecPtr XLogInsert(RmgrId rmid, uint8 info, XLogRecData *rdata); extern void XLogFlush(XLogRecPtr RecPtr); extern void XLogBackgroundFlush(void); @@ -269,7 +271,7 @@ extern int XLogFileOpen(uint32 log, uint32 seg); extern void XLogGetLastRemoved(uint32 *log, uint32 *seg); -extern void XLogSetAsyncCommitLSN(XLogRecPtr record); +extern void XLogSetAsyncXactLSN(XLogRecPtr record); extern void RestoreBkpBlocks(XLogRecPtr lsn, XLogRecord *record, bool cleanup); @@ -278,10 +280,9 @@ extern void xlog_desc(StringInfo buf, uint8 xl_info, char *rec); extern void issue_xlog_fsync(int fd, uint32 log, uint32 seg); -extern bool XLogConsistentState(void); extern bool RecoveryInProgress(void); extern bool XLogInsertAllowed(void); -extern TimestampTz GetLatestXLogTime(void); +extern void GetXLogReceiptTime(TimestampTz *rtime, bool *fromStream); extern void UpdateControlFile(void); extern uint64 GetSystemIdentifier(void); @@ -294,14 +295,14 @@ extern void InitXLOGAccess(void); extern void CreateCheckPoint(int flags); extern bool CreateRestartPoint(int flags); extern void XLogPutNextOid(Oid nextOid); -extern void XLogReportUnloggedStatement(char *reason); extern XLogRecPtr GetRedoRecPtr(void); extern XLogRecPtr GetInsertRecPtr(void); -extern XLogRecPtr GetWriteRecPtr(void); +extern XLogRecPtr GetFlushRecPtr(void); extern void GetNextXidAndEpoch(TransactionId *xid, uint32 *epoch); extern TimeLineID GetRecoveryTargetTLI(void); extern void HandleStartupProcInterrupts(void); extern void StartupProcessMain(void); +extern void WakeupRecovery(void); #endif /* XLOG_H */