Hi all,

Following the discussions done these last days about wal_level like this one:
http://www.postgresql.org/message-id/cabuevewigm-ppobkgdkm6lzyo+ovrdz7soxn_5by8e8pcae...@mail.gmail.com
Please find attached a patch doing what is written in the $subject.

Thoughts?
-- 
Michael
commit 5a06f45ca85e44708e0b6ea6e9af21bc9ff8be90
Author: Michael Paquier <mich...@otacoo.com>
Date:   Mon Nov 4 02:33:32 2013 +0000

    Remove "archive" in wal_level
    
    archive was justifying its existence in the latest releases because
    users could fallback to it if there were any bugs with the latest
    level implemented hot_standby. There haven't been that many bugs in
    this area for the last couple of releases, so why not simply remove
    it if we also know that the performance overhead that hot_standby
    has compared to archive is minimal... It is also usually recommended
    to use hot_standby instead of archive for normal usages.

diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c
index f407753..3333af4 100644
--- a/src/backend/access/nbtree/nbtpage.c
+++ b/src/backend/access/nbtree/nbtpage.c
@@ -630,7 +630,7 @@ _bt_getbuf(Relation rel, BlockNumber blkno, int access)
 					 * WAL record that will allow us to conflict with queries
 					 * running on standby.
 					 */
-					if (XLogStandbyInfoActive())
+					if (XLogIsNeeded())
 					{
 						BTPageOpaque opaque = (BTPageOpaque) PageGetSpecialPointer(page);
 
diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c
index 073190f..81f7c75 100644
--- a/src/backend/access/nbtree/nbtree.c
+++ b/src/backend/access/nbtree/nbtree.c
@@ -826,7 +826,7 @@ btvacuumscan(IndexVacuumInfo *info, IndexBulkDeleteResult *stats,
 	 * take care to issue the record for last actual block and not for the
 	 * last block that was scanned. Ignore empty indexes.
 	 */
-	if (XLogStandbyInfoActive() &&
+	if (XLogIsNeeded() &&
 		num_pages > 1 && vstate.lastBlockVacuumed < (num_pages - 1))
 	{
 		Buffer		buf;
diff --git a/src/backend/access/rmgrdesc/xlogdesc.c b/src/backend/access/rmgrdesc/xlogdesc.c
index 1b36f9a..4735cfb 100644
--- a/src/backend/access/rmgrdesc/xlogdesc.c
+++ b/src/backend/access/rmgrdesc/xlogdesc.c
@@ -26,7 +26,6 @@
  */
 const struct config_enum_entry wal_level_options[] = {
 	{"minimal", WAL_LEVEL_MINIMAL, false},
-	{"archive", WAL_LEVEL_ARCHIVE, false},
 	{"hot_standby", WAL_LEVEL_HOT_STANDBY, false},
 	{NULL, 0, false}
 };
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c
index 0591f3f..75e87f9 100644
--- a/src/backend/access/transam/xact.c
+++ b/src/backend/access/transam/xact.c
@@ -520,7 +520,7 @@ AssignTransactionId(TransactionState s)
 	 * recovery only because aborted subtransactions are separately WAL
 	 * logged.
 	 */
-	if (isSubXact && XLogStandbyInfoActive())
+	if (isSubXact && XLogIsNeeded())
 	{
 		unreportedXids[nUnreportedXids] = s->transactionId;
 		nUnreportedXids++;
@@ -969,7 +969,7 @@ RecordTransactionCommit(void)
 	/* Get data needed for commit record */
 	nrels = smgrGetPendingDeletes(true, &rels);
 	nchildren = xactGetCommittedChildren(&children);
-	if (XLogStandbyInfoActive())
+	if (XLogIsNeeded())
 		nmsgs = xactGetCommittedInvalidationMessages(&invalMessages,
 													 &RelcacheInitFileInval);
 	wrote_xlog = (XactLastRecEnd != 0);
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 06f5eb0..61d28e5 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -7994,7 +7994,7 @@ CreateCheckPoint(int flags)
 	 * pointer. This allows us to begin accumulating changes to assemble our
 	 * starting snapshot of locks and transactions.
 	 */
-	if (!shutdown && XLogStandbyInfoActive())
+	if (!shutdown && XLogIsNeeded())
 		checkPoint.oldestActiveXid = GetOldestActiveTransactionId();
 	else
 		checkPoint.oldestActiveXid = InvalidTransactionId;
@@ -8189,7 +8189,7 @@ CreateCheckPoint(int flags)
 	 * If we are shutting down, or Startup process is completing crash
 	 * recovery we don't need to write running xact data.
 	 */
-	if (!shutdown && XLogStandbyInfoActive())
+	if (!shutdown && XLogIsNeeded())
 		LogStandbySnapshot();
 
 	START_CRIT_SECTION();
@@ -8990,7 +8990,7 @@ UpdateFullPageWrites(void)
 	 * Write an XLOG_FPW_CHANGE record. This allows us to keep track of
 	 * full_page_writes during archive recovery, if required.
 	 */
-	if (XLogStandbyInfoActive() && !RecoveryInProgress())
+	if (XLogIsNeeded() && !RecoveryInProgress())
 	{
 		XLogRecData rdata;
 
diff --git a/src/backend/storage/ipc/standby.c b/src/backend/storage/ipc/standby.c
index c704412..6fd8988 100644
--- a/src/backend/storage/ipc/standby.c
+++ b/src/backend/storage/ipc/standby.c
@@ -753,7 +753,7 @@ StandbyReleaseOldLocks(int nxids, TransactionId *xids)
  * --------------------------------------------------------------------
  *		Recovery handling for Rmgr RM_STANDBY_ID
  *
- * These record types will only be created if XLogStandbyInfoActive()
+ * These record types will only be created if XLogIsNeeded()
  * --------------------------------------------------------------------
  */
 
@@ -861,7 +861,7 @@ LogStandbySnapshot(void)
 	xl_standby_lock *locks;
 	int			nlocks;
 
-	Assert(XLogStandbyInfoActive());
+	Assert(XLogIsNeeded());
 
 	/*
 	 * Get details of any AccessExclusiveLocks being held at the moment.
diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c
index f4f32e9..5cc8c0e 100644
--- a/src/backend/storage/lmgr/lock.c
+++ b/src/backend/storage/lmgr/lock.c
@@ -800,7 +800,7 @@ LockAcquireExtended(const LOCKTAG *locktag,
 	if (lockmode >= AccessExclusiveLock &&
 		locktag->locktag_type == LOCKTAG_RELATION &&
 		!RecoveryInProgress() &&
-		XLogStandbyInfoActive())
+		XLogIsNeeded())
 	{
 		LogAccessExclusiveLockPrepare();
 		log_lock = true;
diff --git a/src/bin/pg_controldata/pg_controldata.c b/src/bin/pg_controldata/pg_controldata.c
index fde483a..655b0b5 100644
--- a/src/bin/pg_controldata/pg_controldata.c
+++ b/src/bin/pg_controldata/pg_controldata.c
@@ -73,8 +73,6 @@ wal_level_str(WalLevel wal_level)
 	{
 		case WAL_LEVEL_MINIMAL:
 			return "minimal";
-		case WAL_LEVEL_ARCHIVE:
-			return "archive";
 		case WAL_LEVEL_HOT_STANDBY:
 			return "hot_standby";
 	}
diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h
index 002862c..1a89034 100644
--- a/src/include/access/xlog.h
+++ b/src/include/access/xlog.h
@@ -196,22 +196,18 @@ extern int	num_xloginsert_slots;
 typedef enum WalLevel
 {
 	WAL_LEVEL_MINIMAL = 0,
-	WAL_LEVEL_ARCHIVE,
 	WAL_LEVEL_HOT_STANDBY
 } WalLevel;
 extern int	wal_level;
 
-#define XLogArchivingActive()	(XLogArchiveMode && wal_level >= WAL_LEVEL_ARCHIVE)
+#define XLogArchivingActive()	(XLogArchiveMode && wal_level >= WAL_LEVEL_HOT_STANDBY)
 #define XLogArchiveCommandSet() (XLogArchiveCommand[0] != '\0')
 
 /*
- * Is WAL-logging necessary for archival or log-shipping, or can we skip
- * WAL-logging if we fsync() the data before committing instead?
+ * Is WAL-logging necessary for log-shipping, or can we skip WAL-logging if we
+ * fsync() the data before committing instead?
  */
-#define XLogIsNeeded() (wal_level >= WAL_LEVEL_ARCHIVE)
-
-/* Do we need to WAL-log information required only for Hot Standby? */
-#define XLogStandbyInfoActive() (wal_level >= WAL_LEVEL_HOT_STANDBY)
+#define XLogIsNeeded() (wal_level >= WAL_LEVEL_HOT_STANDBY)
 
 #ifdef WAL_DEBUG
 extern bool XLOG_DEBUG;
-- 
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

Reply via email to