Skip to content

Commit b555ed8

Browse files
committed
Merge wal_level "archive" and "hot_standby" into new name "replica"
The distinction between "archive" and "hot_standby" existed only because at the time "hot_standby" was added, there was some uncertainty about stability. This is now a long time ago. We would like to move forward with simplifying the replication configuration, but this distinction is in the way, because a primary server cannot tell (without asking a standby or predicting the future) which one of these would be the appropriate level. Pick a new name for the combined setting to make it clearer that it covers all (non-logical) backup and replication uses. The old values are still accepted but are converted internally. Reviewed-by: Michael Paquier <michael.paquier@gmail.com> Reviewed-by: David Steele <david@pgmasters.net>
1 parent 4e1d2a1 commit b555ed8

File tree

17 files changed

+44
-54
lines changed

17 files changed

+44
-54
lines changed

doc/src/sgml/backup.sgml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ tar -cf backup.tar /usr/local/pgsql/data
592592

593593
<para>
594594
To enable WAL archiving, set the <xref linkend="guc-wal-level">
595-
configuration parameter to <literal>archive</> or higher,
595+
configuration parameter to <literal>replica</> or higher,
596596
<xref linkend="guc-archive-mode"> to <literal>on</>,
597597
and specify the shell command to use in the <xref
598598
linkend="guc-archive-command"> configuration parameter. In practice
@@ -1285,7 +1285,7 @@ restore_command = 'cp /mnt/server/archivedir/%f %p'
12851285
If more flexibility in copying the backup files is needed, a lower
12861286
level process can be used for standalone hot backups as well.
12871287
To prepare for low level standalone hot backups, set <varname>wal_level</> to
1288-
<literal>archive</> or higher, <varname>archive_mode</> to
1288+
<literal>replica</> or higher, <varname>archive_mode</> to
12891289
<literal>on</>, and set up an <varname>archive_command</> that performs
12901290
archiving only when a <emphasis>switch file</> exists. For example:
12911291
<programlisting>

doc/src/sgml/config.sgml

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2029,9 +2029,9 @@ include_dir 'conf.d'
20292029
<varname>wal_level</> determines how much information is written
20302030
to the WAL. The default value is <literal>minimal</>, which writes
20312031
only the information needed to recover from a crash or immediate
2032-
shutdown. <literal>archive</> adds logging required for WAL archiving;
2033-
<literal>hot_standby</> further adds information required to run
2034-
read-only queries on a standby server; and, finally
2032+
shutdown. <literal>replica</> adds logging required for WAL
2033+
archiving as well as information required to run
2034+
read-only queries on a standby server. Finally,
20352035
<literal>logical</> adds information necessary to support logical
20362036
decoding. Each level includes the information logged at all lower
20372037
levels. This parameter can only be set at server start.
@@ -2049,30 +2049,24 @@ include_dir 'conf.d'
20492049
transaction</member>
20502050
</simplelist>
20512051
But minimal WAL does not contain enough information to reconstruct the
2052-
data from a base backup and the WAL logs, so <literal>archive</> or
2052+
data from a base backup and the WAL logs, so <literal>replica</> or
20532053
higher must be used to enable WAL archiving
20542054
(<xref linkend="guc-archive-mode">) and streaming replication.
20552055
</para>
2056-
<para>
2057-
In <literal>hot_standby</> level, the same information is logged as
2058-
with <literal>archive</>, plus information needed to reconstruct
2059-
the status of running transactions from the WAL. To enable read-only
2060-
queries on a standby server, <varname>wal_level</> must be set to
2061-
<literal>hot_standby</> or higher on the primary, and
2062-
<xref linkend="guc-hot-standby"> must be enabled in the standby. It is
2063-
thought that there is little measurable difference in performance
2064-
between using <literal>hot_standby</> and <literal>archive</> levels,
2065-
so feedback is welcome if any production impacts are noticeable.
2066-
</para>
20672056
<para>
20682057
In <literal>logical</> level, the same information is logged as
2069-
with <literal>hot_standby</>, plus information needed to allow
2058+
with <literal>replica</>, plus information needed to allow
20702059
extracting logical change sets from the WAL. Using a level of
20712060
<literal>logical</> will increase the WAL volume, particularly if many
20722061
tables are configured for <literal>REPLICA IDENTITY FULL</literal> and
20732062
many <command>UPDATE</> and <command>DELETE</> statements are
20742063
executed.
20752064
</para>
2065+
<para>
2066+
In releases prior to 9.6, this parameter also allowed the
2067+
values <literal>archive</literal> and <literal>hot_standby</literal>.
2068+
These are still accepted but mapped to <literal>replica</literal>.
2069+
</para>
20762070
</listitem>
20772071
</varlistentry>
20782072

@@ -2784,7 +2778,7 @@ include_dir 'conf.d'
27842778
higher than the maximum number of expected clients so disconnected
27852779
clients can immediately reconnect. This parameter can only
27862780
be set at server start. <varname>wal_level</> must be set to
2787-
<literal>archive</> or higher to allow connections from standby
2781+
<literal>replica</> or higher to allow connections from standby
27882782
servers.
27892783
</para>
27902784
</listitem>
@@ -2803,7 +2797,7 @@ include_dir 'conf.d'
28032797
can support. The default is zero. This parameter can only be set at
28042798
server start.
28052799
<varname>wal_level</varname> must be set
2806-
to <literal>archive</literal> or higher to allow replication slots to
2800+
to <literal>replica</literal> or higher to allow replication slots to
28072801
be used. Setting it to a lower value than the number of currently
28082802
existing replication slots will prevent the server from starting.
28092803
</para>

doc/src/sgml/high-availability.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1988,7 +1988,7 @@ LOG: database system is ready to accept read only connections
19881988
Consistency information is recorded once per checkpoint on the primary.
19891989
It is not possible to enable hot standby when reading WAL
19901990
written during a period when <varname>wal_level</> was not set to
1991-
<literal>hot_standby</> or <literal>logical</> on the primary. Reaching
1991+
<literal>replica</> or <literal>logical</> on the primary. Reaching
19921992
a consistent state can also be delayed in the presence of both of these
19931993
conditions:
19941994

doc/src/sgml/ref/alter_system.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ ALTER SYSTEM RESET ALL
108108
<para>
109109
Set the <literal>wal_level</>:
110110
<programlisting>
111-
ALTER SYSTEM SET wal_level = hot_standby;
111+
ALTER SYSTEM SET wal_level = replica;
112112
</programlisting>
113113
</para>
114114

doc/src/sgml/ref/pgupgrade.sgml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ pg_upgrade.exe
477477

478478
<para>
479479
In the new master cluster, change <varname>wal_level</> to
480-
<literal>hot_standby</> in the <filename>postgresql.conf</> file
480+
<literal>replica</> in the <filename>postgresql.conf</> file
481481
and then start and stop the cluster.
482482
</para>
483483
</step>

src/backend/access/rmgrdesc/xlogdesc.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,9 @@
2525
*/
2626
const struct config_enum_entry wal_level_options[] = {
2727
{"minimal", WAL_LEVEL_MINIMAL, false},
28-
{"archive", WAL_LEVEL_ARCHIVE, false},
29-
{"hot_standby", WAL_LEVEL_HOT_STANDBY, false},
28+
{"replica", WAL_LEVEL_REPLICA, false},
29+
{"archive", WAL_LEVEL_REPLICA, true}, /* deprecated */
30+
{"hot_standby", WAL_LEVEL_REPLICA, true}, /* deprecated */
3031
{"logical", WAL_LEVEL_LOGICAL, false},
3132
{NULL, 0, false}
3233
};

src/backend/access/transam/xact.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1254,7 +1254,7 @@ RecordTransactionCommit(void)
12541254
* this case, but we don't currently try to do that. It would certainly
12551255
* cause problems at least in Hot Standby mode, where the
12561256
* KnownAssignedXids machinery requires tracking every XID assignment. It
1257-
* might be OK to skip it only when wal_level < hot_standby, but for now
1257+
* might be OK to skip it only when wal_level < replica, but for now
12581258
* we don't.)
12591259
*
12601260
* However, if we're doing cleanup of any non-temp rels or committing any

src/backend/access/transam/xlog.c

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5866,7 +5866,7 @@ static void
58665866
CheckRequiredParameterValues(void)
58675867
{
58685868
/*
5869-
* For archive recovery, the WAL must be generated with at least 'archive'
5869+
* For archive recovery, the WAL must be generated with at least 'replica'
58705870
* wal_level.
58715871
*/
58725872
if (ArchiveRecoveryRequested && ControlFile->wal_level == WAL_LEVEL_MINIMAL)
@@ -5877,15 +5877,15 @@ CheckRequiredParameterValues(void)
58775877
}
58785878

58795879
/*
5880-
* For Hot Standby, the WAL must be generated with 'hot_standby' mode, and
5880+
* For Hot Standby, the WAL must be generated with 'replica' mode, and
58815881
* we must have at least as many backend slots as the primary.
58825882
*/
58835883
if (ArchiveRecoveryRequested && EnableHotStandby)
58845884
{
5885-
if (ControlFile->wal_level < WAL_LEVEL_HOT_STANDBY)
5885+
if (ControlFile->wal_level < WAL_LEVEL_REPLICA)
58865886
ereport(ERROR,
5887-
(errmsg("hot standby is not possible because wal_level was not set to \"hot_standby\" or higher on the master server"),
5888-
errhint("Either set wal_level to \"hot_standby\" on the master, or turn off hot_standby here.")));
5887+
(errmsg("hot standby is not possible because wal_level was not set to \"replica\" or higher on the master server"),
5888+
errhint("Either set wal_level to \"replica\" on the master, or turn off hot_standby here.")));
58895889

58905890
/* We ignore autovacuum_max_workers when we make this test. */
58915891
RecoveryRequiresIntParameter("max_connections",
@@ -9459,10 +9459,8 @@ xlog_redo(XLogReaderState *record)
94599459
/*
94609460
* Update minRecoveryPoint to ensure that if recovery is aborted, we
94619461
* recover back up to this point before allowing hot standby again.
9462-
* This is particularly important if wal_level was set to 'archive'
9463-
* before, and is now 'hot_standby', to ensure you don't run queries
9464-
* against the WAL preceding the wal_level change. Same applies to
9465-
* decreasing max_* settings.
9462+
* This is important if the max_* settings are decreased, to ensure
9463+
* you don't run queries against the WAL preceding the change.
94669464
*/
94679465
minRecoveryPoint = ControlFile->minRecoveryPoint;
94689466
minRecoveryPointTLI = ControlFile->minRecoveryPointTLI;
@@ -9793,7 +9791,7 @@ do_pg_start_backup(const char *backupidstr, bool fast, TimeLineID *starttli_p,
97939791
ereport(ERROR,
97949792
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
97959793
errmsg("WAL level not sufficient for making an online backup"),
9796-
errhint("wal_level must be set to \"archive\", \"hot_standby\", or \"logical\" at server start.")));
9794+
errhint("wal_level must be set to \"replica\" or \"logical\" at server start.")));
97979795

97989796
if (strlen(backupidstr) > MAXPGPATH)
97999797
ereport(ERROR,
@@ -10264,7 +10262,7 @@ do_pg_stop_backup(char *labelfile, bool waitforarchive, TimeLineID *stoptli_p)
1026410262
ereport(ERROR,
1026510263
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1026610264
errmsg("WAL level not sufficient for making an online backup"),
10267-
errhint("wal_level must be set to \"archive\", \"hot_standby\", or \"logical\" at server start.")));
10265+
errhint("wal_level must be set to \"replica\" or \"logical\" at server start.")));
1026810266

1026910267
/*
1027010268
* OK to update backup counters and forcePageWrites

src/backend/access/transam/xlogfuncs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ pg_create_restore_point(PG_FUNCTION_ARGS)
154154
ereport(ERROR,
155155
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
156156
errmsg("WAL level not sufficient for creating a restore point"),
157-
errhint("wal_level must be set to \"archive\", \"hot_standby\", or \"logical\" at server start.")));
157+
errhint("wal_level must be set to \"replica\" or \"logical\" at server start.")));
158158

159159
restore_name_str = text_to_cstring(restore_name);
160160

src/backend/postmaster/postmaster.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,7 @@ PostmasterMain(int argc, char *argv[])
858858
(errmsg("WAL archival cannot be enabled when wal_level is \"minimal\"")));
859859
if (max_wal_senders > 0 && wal_level == WAL_LEVEL_MINIMAL)
860860
ereport(ERROR,
861-
(errmsg("WAL streaming (max_wal_senders > 0) requires wal_level \"archive\", \"hot_standby\", or \"logical\"")));
861+
(errmsg("WAL streaming (max_wal_senders > 0) requires wal_level \"replica\" or \"logical\"")));
862862

863863
/*
864864
* Other one-time internal sanity checks can go here, if they are fast.

src/backend/replication/slot.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ CheckSlotRequirements(void)
760760
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
761761
(errmsg("replication slots can only be used if max_replication_slots > 0"))));
762762

763-
if (wal_level < WAL_LEVEL_ARCHIVE)
763+
if (wal_level < WAL_LEVEL_REPLICA)
764764
ereport(ERROR,
765765
(errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
766766
errmsg("replication slots can only be used if wal_level >= archive")));

src/backend/utils/misc/postgresql.conf.sample

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@
173173

174174
# - Settings -
175175

176-
#wal_level = minimal # minimal, archive, hot_standby, or logical
176+
#wal_level = minimal # minimal, replica, or logical
177177
# (change requires restart)
178178
#fsync = on # turns forced synchronization on or off
179179
#synchronous_commit = on # synchronization level;

src/bin/pg_basebackup/t/010_pg_basebackup.pl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
open CONF, ">>$pgdata/postgresql.conf";
4444
print CONF "max_replication_slots = 10\n";
4545
print CONF "max_wal_senders = 10\n";
46-
print CONF "wal_level = archive\n";
46+
print CONF "wal_level = replica\n";
4747
close CONF;
4848
$node->restart;
4949

src/bin/pg_controldata/pg_controldata.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,8 @@ wal_level_str(WalLevel wal_level)
7373
{
7474
case WAL_LEVEL_MINIMAL:
7575
return "minimal";
76-
case WAL_LEVEL_ARCHIVE:
77-
return "archive";
78-
case WAL_LEVEL_HOT_STANDBY:
79-
return "hot_standby";
76+
case WAL_LEVEL_REPLICA:
77+
return "replica";
8078
case WAL_LEVEL_LOGICAL:
8179
return "logical";
8280
}

src/include/access/xlog.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,25 +121,24 @@ extern int XLogArchiveMode;
121121
typedef enum WalLevel
122122
{
123123
WAL_LEVEL_MINIMAL = 0,
124-
WAL_LEVEL_ARCHIVE,
125-
WAL_LEVEL_HOT_STANDBY,
124+
WAL_LEVEL_REPLICA,
126125
WAL_LEVEL_LOGICAL
127126
} WalLevel;
128127
extern int wal_level;
129128

130129
/* Is WAL archiving enabled (always or only while server is running normally)? */
131130
#define XLogArchivingActive() \
132-
(XLogArchiveMode > ARCHIVE_MODE_OFF && wal_level >= WAL_LEVEL_ARCHIVE)
131+
(AssertMacro(XLogArchiveMode == ARCHIVE_MODE_OFF || wal_level >= WAL_LEVEL_REPLICA), XLogArchiveMode > ARCHIVE_MODE_OFF)
133132
/* Is WAL archiving enabled always (even during recovery)? */
134133
#define XLogArchivingAlways() \
135-
(XLogArchiveMode == ARCHIVE_MODE_ALWAYS && wal_level >= WAL_LEVEL_ARCHIVE)
134+
(AssertMacro(XLogArchiveMode == ARCHIVE_MODE_OFF || wal_level >= WAL_LEVEL_REPLICA), XLogArchiveMode == ARCHIVE_MODE_ALWAYS)
136135
#define XLogArchiveCommandSet() (XLogArchiveCommand[0] != '\0')
137136

138137
/*
139138
* Is WAL-logging necessary for archival or log-shipping, or can we skip
140139
* WAL-logging if we fsync() the data before committing instead?
141140
*/
142-
#define XLogIsNeeded() (wal_level >= WAL_LEVEL_ARCHIVE)
141+
#define XLogIsNeeded() (wal_level >= WAL_LEVEL_REPLICA)
143142

144143
/*
145144
* Is a full-page image needed for hint bit updates?
@@ -153,7 +152,7 @@ extern int wal_level;
153152
#define XLogHintBitIsNeeded() (DataChecksumsEnabled() || wal_log_hints)
154153

155154
/* Do we need to WAL-log information required only for Hot Standby and logical replication? */
156-
#define XLogStandbyInfoActive() (wal_level >= WAL_LEVEL_HOT_STANDBY)
155+
#define XLogStandbyInfoActive() (wal_level >= WAL_LEVEL_REPLICA)
157156

158157
/* Do we need to WAL-log information required only for logical replication? */
159158
#define XLogLogicalInfoActive() (wal_level >= WAL_LEVEL_LOGICAL)

src/include/catalog/pg_control.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ typedef struct CheckPoint
5454
/*
5555
* Oldest XID still running. This is only needed to initialize hot standby
5656
* mode from an online checkpoint, so we only bother calculating this for
57-
* online checkpoints and only when wal_level is hot_standby. Otherwise
57+
* online checkpoints and only when wal_level is replica. Otherwise
5858
* it's set to InvalidTransactionId.
5959
*/
6060
TransactionId oldestActiveXid;

src/test/perl/PostgresNode.pm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ sub init
404404

405405
if ($params{allows_streaming})
406406
{
407-
print $conf "wal_level = hot_standby\n";
407+
print $conf "wal_level = replica\n";
408408
print $conf "max_wal_senders = 5\n";
409409
print $conf "wal_keep_segments = 20\n";
410410
print $conf "max_wal_size = 128MB\n";

0 commit comments

Comments
 (0)