To enable WAL archiving, set the
- configuration parameter to archive> or higher,
+ configuration parameter to replica> or higher,
to on>,
and specify the shell command to use in the
linkend="guc-archive-command"> configuration parameter. In practice
If more flexibility in copying the backup files is needed, a lower
level process can be used for standalone hot backups as well.
To prepare for low level standalone hot backups, set wal_level> to
- archive> or higher, archive_mode> to
+ replica> or higher, archive_mode> to
on>, and set up an archive_command> that performs
archiving only when a switch file> exists. For example:
wal_level> determines how much information is written
to the WAL. The default value is minimal>, which writes
only the information needed to recover from a crash or immediate
- shutdown. archive> adds logging required for WAL archiving;
- hot_standby> further adds information required to run
- read-only queries on a standby server; and, finally
+ shutdown. replica> adds logging required for WAL
+ archiving as well as information required to run
+ read-only queries on a standby server. Finally,
logical> adds information necessary to support logical
decoding. Each level includes the information logged at all lower
levels. This parameter can only be set at server start.
transaction
But minimal WAL does not contain enough information to reconstruct the
- data from a base backup and the WAL logs, so archive> or
+ data from a base backup and the WAL logs, so replica> or
higher must be used to enable WAL archiving
() and streaming replication.
- In hot_standby> level, the same information is logged as
- with archive>, plus information needed to reconstruct
- the status of running transactions from the WAL. To enable read-only
- queries on a standby server, wal_level> must be set to
- hot_standby> or higher on the primary, and
- must be enabled in the standby. It is
- thought that there is little measurable difference in performance
- between using hot_standby> and archive> levels,
- so feedback is welcome if any production impacts are noticeable.
-
In logical> level, the same information is logged as
- with hot_standby>, plus information needed to allow
+ with replica>, plus information needed to allow
extracting logical change sets from the WAL. Using a level of
logical> will increase the WAL volume, particularly if many
tables are configured for REPLICA IDENTITY FULL and
many UPDATE> and DELETE> statements are
executed.
+ In releases prior to 9.6, this parameter also allowed the
+ values archive and hot_standby.
+ These are still accepted but mapped to replica.
+
higher than the maximum number of expected clients so disconnected
clients can immediately reconnect. This parameter can only
be set at server start. wal_level> must be set to
- archive> or higher to allow connections from standby
+ replica> or higher to allow connections from standby
servers.
can support. The default is zero. This parameter can only be set at
server start.
wal_level must be set
- to archive or higher to allow replication slots to
+ to replica or higher to allow replication slots to
be used. Setting it to a lower value than the number of currently
existing replication slots will prevent the server from starting.
Consistency information is recorded once per checkpoint on the primary.
It is not possible to enable hot standby when reading WAL
written during a period when wal_level> was not set to
- hot_standby> or logical> on the primary. Reaching
+ replica> or logical> on the primary. Reaching
a consistent state can also be delayed in the presence of both of these
conditions:
Set the wal_level>:
-ALTER SYSTEM SET wal_level = hot_standby;
+ALTER SYSTEM SET wal_level = replica;
In the new master cluster, change wal_level> to
- hot_standby> in the postgresql.conf> file
+ replica> in the postgresql.conf> file
and then start and stop the cluster.
*/
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},
+ {"replica", WAL_LEVEL_REPLICA, false},
+ {"archive", WAL_LEVEL_REPLICA, true}, /* deprecated */
+ {"hot_standby", WAL_LEVEL_REPLICA, true}, /* deprecated */
{"logical", WAL_LEVEL_LOGICAL, false},
{NULL, 0, false}
};
* this case, but we don't currently try to do that. It would certainly
* cause problems at least in Hot Standby mode, where the
* KnownAssignedXids machinery requires tracking every XID assignment. It
- * might be OK to skip it only when wal_level < hot_standby, but for now
+ * might be OK to skip it only when wal_level < replica, but for now
* we don't.)
*
* However, if we're doing cleanup of any non-temp rels or committing any
CheckRequiredParameterValues(void)
{
/*
- * For archive recovery, the WAL must be generated with at least 'archive'
+ * For archive recovery, the WAL must be generated with at least 'replica'
* wal_level.
*/
if (ArchiveRecoveryRequested && ControlFile->wal_level == WAL_LEVEL_MINIMAL)
}
/*
- * For Hot Standby, the WAL must be generated with 'hot_standby' mode, and
+ * For Hot Standby, the WAL must be generated with 'replica' mode, and
* we must have at least as many backend slots as the primary.
*/
if (ArchiveRecoveryRequested && EnableHotStandby)
{
- if (ControlFile->wal_level < WAL_LEVEL_HOT_STANDBY)
+ if (ControlFile->wal_level < WAL_LEVEL_REPLICA)
ereport(ERROR,
- (errmsg("hot standby is not possible because wal_level was not set to \"hot_standby\" or higher on the master server"),
- errhint("Either set wal_level to \"hot_standby\" on the master, or turn off hot_standby here.")));
+ (errmsg("hot standby is not possible because wal_level was not set to \"replica\" or higher on the master server"),
+ errhint("Either set wal_level to \"replica\" on the master, or turn off hot_standby here.")));
/* We ignore autovacuum_max_workers when we make this test. */
RecoveryRequiresIntParameter("max_connections",
/*
* Update minRecoveryPoint to ensure that if recovery is aborted, we
* recover back up to this point before allowing hot standby again.
- * This is particularly important if wal_level was set to 'archive'
- * before, and is now 'hot_standby', to ensure you don't run queries
- * against the WAL preceding the wal_level change. Same applies to
- * decreasing max_* settings.
+ * This is important if the max_* settings are decreased, to ensure
+ * you don't run queries against the WAL preceding the change.
*/
minRecoveryPoint = ControlFile->minRecoveryPoint;
minRecoveryPointTLI = ControlFile->minRecoveryPointTLI;
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("WAL level not sufficient for making an online backup"),
- errhint("wal_level must be set to \"archive\", \"hot_standby\", or \"logical\" at server start.")));
+ errhint("wal_level must be set to \"replica\" or \"logical\" at server start.")));
if (strlen(backupidstr) > MAXPGPATH)
ereport(ERROR,
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("WAL level not sufficient for making an online backup"),
- errhint("wal_level must be set to \"archive\", \"hot_standby\", or \"logical\" at server start.")));
+ errhint("wal_level must be set to \"replica\" or \"logical\" at server start.")));
/*
* OK to update backup counters and forcePageWrites
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("WAL level not sufficient for creating a restore point"),
- errhint("wal_level must be set to \"archive\", \"hot_standby\", or \"logical\" at server start.")));
+ errhint("wal_level must be set to \"replica\" or \"logical\" at server start.")));
restore_name_str = text_to_cstring(restore_name);
(errmsg("WAL archival cannot be enabled when wal_level is \"minimal\"")));
if (max_wal_senders > 0 && wal_level == WAL_LEVEL_MINIMAL)
ereport(ERROR,
- (errmsg("WAL streaming (max_wal_senders > 0) requires wal_level \"archive\", \"hot_standby\", or \"logical\"")));
+ (errmsg("WAL streaming (max_wal_senders > 0) requires wal_level \"replica\" or \"logical\"")));
/*
* Other one-time internal sanity checks can go here, if they are fast.
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
(errmsg("replication slots can only be used if max_replication_slots > 0"))));
- if (wal_level < WAL_LEVEL_ARCHIVE)
+ if (wal_level < WAL_LEVEL_REPLICA)
ereport(ERROR,
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
errmsg("replication slots can only be used if wal_level >= archive")));
# - Settings -
-#wal_level = minimal # minimal, archive, hot_standby, or logical
+#wal_level = minimal # minimal, replica, or logical
# (change requires restart)
#fsync = on # turns forced synchronization on or off
#synchronous_commit = on # synchronization level;
open CONF, ">>$pgdata/postgresql.conf";
print CONF "max_replication_slots = 10\n";
print CONF "max_wal_senders = 10\n";
-print CONF "wal_level = archive\n";
+print CONF "wal_level = replica\n";
close CONF;
$node->restart;
{
case WAL_LEVEL_MINIMAL:
return "minimal";
- case WAL_LEVEL_ARCHIVE:
- return "archive";
- case WAL_LEVEL_HOT_STANDBY:
- return "hot_standby";
+ case WAL_LEVEL_REPLICA:
+ return "replica";
case WAL_LEVEL_LOGICAL:
return "logical";
}
typedef enum WalLevel
{
WAL_LEVEL_MINIMAL = 0,
- WAL_LEVEL_ARCHIVE,
- WAL_LEVEL_HOT_STANDBY,
+ WAL_LEVEL_REPLICA,
WAL_LEVEL_LOGICAL
} WalLevel;
extern int wal_level;
/* Is WAL archiving enabled (always or only while server is running normally)? */
#define XLogArchivingActive() \
- (XLogArchiveMode > ARCHIVE_MODE_OFF && wal_level >= WAL_LEVEL_ARCHIVE)
+ (AssertMacro(XLogArchiveMode == ARCHIVE_MODE_OFF || wal_level >= WAL_LEVEL_REPLICA), XLogArchiveMode > ARCHIVE_MODE_OFF)
/* Is WAL archiving enabled always (even during recovery)? */
#define XLogArchivingAlways() \
- (XLogArchiveMode == ARCHIVE_MODE_ALWAYS && wal_level >= WAL_LEVEL_ARCHIVE)
+ (AssertMacro(XLogArchiveMode == ARCHIVE_MODE_OFF || wal_level >= WAL_LEVEL_REPLICA), XLogArchiveMode == ARCHIVE_MODE_ALWAYS)
#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?
*/
-#define XLogIsNeeded() (wal_level >= WAL_LEVEL_ARCHIVE)
+#define XLogIsNeeded() (wal_level >= WAL_LEVEL_REPLICA)
/*
* Is a full-page image needed for hint bit updates?
#define XLogHintBitIsNeeded() (DataChecksumsEnabled() || wal_log_hints)
/* Do we need to WAL-log information required only for Hot Standby and logical replication? */
-#define XLogStandbyInfoActive() (wal_level >= WAL_LEVEL_HOT_STANDBY)
+#define XLogStandbyInfoActive() (wal_level >= WAL_LEVEL_REPLICA)
/* Do we need to WAL-log information required only for logical replication? */
#define XLogLogicalInfoActive() (wal_level >= WAL_LEVEL_LOGICAL)
/*
* Oldest XID still running. This is only needed to initialize hot standby
* mode from an online checkpoint, so we only bother calculating this for
- * online checkpoints and only when wal_level is hot_standby. Otherwise
+ * online checkpoints and only when wal_level is replica. Otherwise
* it's set to InvalidTransactionId.
*/
TransactionId oldestActiveXid;
if ($params{allows_streaming})
{
- print $conf "wal_level = hot_standby\n";
+ print $conf "wal_level = replica\n";
print $conf "max_wal_senders = 5\n";
print $conf "wal_keep_segments = 20\n";
print $conf "max_wal_size = 128MB\n";