diff options
| author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2010-04-28 16:10:43 +0000 |
|---|---|---|
| committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2010-04-28 16:10:43 +0000 |
| commit | 9b8a73326e99821caf33c36c081cb307e17422d4 (patch) | |
| tree | 6ba969ff6d18829c87fde36b9608f4d051cc7b8c /src/include | |
| parent | a2de4826e912057a9a3c44e6c4c204dfa3b753a9 (diff) | |
| download | postgresql-9b8a73326e99821caf33c36c081cb307e17422d4.tar.gz | |
Introduce wal_level GUC to explicitly control if information needed for
archival or hot standby should be WAL-logged, instead of deducing that from
other options like archive_mode. This replaces recovery_connections GUC in
the primary, where it now has no effect, but it's still used in the standby
to enable/disable hot standby.
Remove the WAL-logging of "unlogged operations", like creating an index
without WAL-logging and fsyncing it at the end. Instead, we keep a copy of
the wal_mode setting and the settings that affect how much shared memory a
hot standby server needs to track master transactions (max_connections,
max_prepared_xacts, max_locks_per_xact) in pg_control. Whenever the settings
change, at server restart, write a WAL record noting the new settings and
update pg_control. This allows us to notice the change in those settings in
the standby at the right moment, they used to be included in checkpoint
records, but that meant that a changed value was not reflected in the
standby until the first checkpoint after the change.
Bump PG_CONTROL_VERSION and XLOG_PAGE_MAGIC. Whack XLOG_PAGE_MAGIC back to
the sequence it used to follow, before hot standby and subsequent patches
changed it to 0x9003.
Diffstat (limited to 'src/include')
| -rw-r--r-- | src/include/access/xlog.h | 27 | ||||
| -rw-r--r-- | src/include/access/xlog_internal.h | 4 | ||||
| -rw-r--r-- | src/include/catalog/pg_control.h | 21 | ||||
| -rw-r--r-- | src/include/replication/walsender.h | 3 |
4 files changed, 30 insertions, 25 deletions
diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h index 4812997659..6936a2a579 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.109 2010/04/20 11:15:06 rhaas Exp $ + * $PostgreSQL: pgsql/src/include/access/xlog.h,v 1.110 2010/04/28 16:10:43 heikki Exp $ */ #ifndef XLOG_H #define XLOG_H @@ -195,24 +195,26 @@ extern int XLogArchiveTimeout; extern bool log_checkpoints; extern bool XLogRequestRecoveryConnections; extern int MaxStandbyDelay; +/* WAL levels */ +typedef enum WalLevel +{ + WAL_LEVEL_MINIMAL = 0, + WAL_LEVEL_ARCHIVE, + WAL_LEVEL_HOT_STANDBY +} WalLevel; +extern int wal_level; -#define XLogArchivingActive() (XLogArchiveMode) +#define XLogArchivingActive() (XLogArchiveMode && wal_level >= WAL_LEVEL_ARCHIVE) #define XLogArchiveCommandSet() (XLogArchiveCommand[0] != '\0') /* - * 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; - -/* - * 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; @@ -293,7 +295,6 @@ 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); diff --git a/src/include/access/xlog_internal.h b/src/include/access/xlog_internal.h index fa21f0a916..3f0930f395 100644 --- a/src/include/access/xlog_internal.h +++ b/src/include/access/xlog_internal.h @@ -11,7 +11,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_internal.h,v 1.32 2010/04/12 10:40:43 heikki Exp $ + * $PostgreSQL: pgsql/src/include/access/xlog_internal.h,v 1.33 2010/04/28 16:10:43 heikki Exp $ */ #ifndef XLOG_INTERNAL_H #define XLOG_INTERNAL_H @@ -71,7 +71,7 @@ typedef struct XLogContRecord /* * Each page of XLOG file has a header like this: */ -#define XLOG_PAGE_MAGIC 0x9003 /* can be used as WAL version indicator */ +#define XLOG_PAGE_MAGIC 0xD064 /* can be used as WAL version indicator */ typedef struct XLogPageHeaderData { diff --git a/src/include/catalog/pg_control.h b/src/include/catalog/pg_control.h index 7342468d05..8deef6d354 100644 --- a/src/include/catalog/pg_control.h +++ b/src/include/catalog/pg_control.h @@ -8,7 +8,7 @@ * Portions Copyright (c) 1996-2010, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $PostgreSQL: pgsql/src/include/catalog/pg_control.h,v 1.53 2010/04/23 20:21:31 sriggs Exp $ + * $PostgreSQL: pgsql/src/include/catalog/pg_control.h,v 1.54 2010/04/28 16:10:43 heikki Exp $ * *------------------------------------------------------------------------- */ @@ -21,7 +21,7 @@ /* Version identifier for this pg_control format */ -#define PG_CONTROL_VERSION 901 +#define PG_CONTROL_VERSION 902 /* * Body of CheckPoint XLOG records. This is declared here because we keep @@ -41,12 +41,6 @@ typedef struct CheckPoint Oid oldestXidDB; /* database with minimum datfrozenxid */ pg_time_t time; /* time stamp of checkpoint */ - /* Important parameter settings at time of shutdown checkpoints */ - int MaxConnections; - int max_prepared_xacts; - int max_locks_per_xact; - bool XLogStandbyInfoMode; - /* * Oldest XID still running. This is only needed to initialize hot standby * mode from an online checkpoint, so we only bother calculating this for @@ -63,7 +57,7 @@ typedef struct CheckPoint #define XLOG_NEXTOID 0x30 #define XLOG_SWITCH 0x40 #define XLOG_BACKUP_END 0x50 -#define XLOG_UNLOGGED 0x60 +#define XLOG_PARAMETER_CHANGE 0x60 /* System status indicator */ @@ -142,6 +136,15 @@ typedef struct ControlFileData XLogRecPtr backupStartPoint; /* + * Parameter settings that determine if the WAL can be used for archival + * or hot standby. + */ + int wal_level; + int MaxConnections; + int max_prepared_xacts; + int max_locks_per_xact; + + /* * This data is used to check for hardware-architecture compatibility of * the database and the backend executable. We need not check endianness * explicitly, since the pg_control version will surely look wrong to a diff --git a/src/include/replication/walsender.h b/src/include/replication/walsender.h index abb8312ecf..d43ad912e7 100644 --- a/src/include/replication/walsender.h +++ b/src/include/replication/walsender.h @@ -5,7 +5,7 @@ * * Portions Copyright (c) 2010-2010, PostgreSQL Global Development Group * - * $PostgreSQL: pgsql/src/include/replication/walsender.h,v 1.2 2010/02/26 02:01:27 momjian Exp $ + * $PostgreSQL: pgsql/src/include/replication/walsender.h,v 1.3 2010/04/28 16:10:43 heikki Exp $ * *------------------------------------------------------------------------- */ @@ -39,6 +39,7 @@ extern bool am_walsender; /* user-settable parameters */ extern int WalSndDelay; +extern int max_wal_senders; extern int WalSenderMain(void); extern void WalSndSignals(void); |
