From c3fe108c025e4a080315562d4c15ecbe3f00405e Mon Sep 17 00:00:00 2001 From: Fujii Masao Date: Mon, 20 Jul 2020 13:30:18 +0900 Subject: Rename wal_keep_segments to wal_keep_size. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit max_slot_wal_keep_size that was added in v13 and wal_keep_segments are the GUC parameters to specify how much WAL files to retain for the standby servers. While max_slot_wal_keep_size accepts the number of bytes of WAL files, wal_keep_segments accepts the number of WAL files. This difference of setting units between those similar parameters could be confusing to users. To alleviate this situation, this commit renames wal_keep_segments to wal_keep_size, and make users specify the WAL size in it instead of the number of WAL files. There was also the idea to rename max_slot_wal_keep_size to max_slot_wal_keep_segments, in the discussion. But we have been moving away from measuring in segments, for example, checkpoint_segments was replaced by max_wal_size. So we concluded to rename wal_keep_segments to wal_keep_size. Back-patch to v13 where max_slot_wal_keep_size was added. Author: Fujii Masao Reviewed-by: Álvaro Herrera, Kyotaro Horiguchi, David Steele Discussion: https://postgr.es/m/574b4ea3-e0f9-b175-ead2-ebea7faea855@oss.nttdata.com --- doc/src/sgml/catalogs.sgml | 2 +- doc/src/sgml/config.sgml | 21 +++++++++++---------- doc/src/sgml/high-availability.sgml | 4 ++-- doc/src/sgml/ref/pg_basebackup.sgml | 2 +- doc/src/sgml/wal.sgml | 3 ++- 5 files changed, 17 insertions(+), 15 deletions(-) (limited to 'doc/src') diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index 9f00ea90e32..048ff284f76 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -11278,7 +11278,7 @@ SELECT * FROM pg_locks pl LEFT JOIN pg_prepared_xacts ppx extended means that max_wal_size is exceeded but the files are still retained, either by the replication slot or - by wal_keep_segments. + by wal_keep_size. diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 1c491fb8ffc..ca6a3a523ff 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -3151,7 +3151,7 @@ include_dir 'conf.d' checkpoints. This is a soft limit; WAL size can exceed max_wal_size under special circumstances, such as heavy load, a failing archive_command, or a high - wal_keep_segments setting. + wal_keep_size setting. If this value is specified without units, it is taken as megabytes. The default is 1 GB. Increasing this parameter can increase the amount of time needed for @@ -3778,21 +3778,21 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows - - wal_keep_segments (integer) + + wal_keep_size (integer) - wal_keep_segments configuration parameter + wal_keep_size configuration parameter - Specifies the minimum number of past log file segments kept in the + Specifies the minimum size of past log file segments kept in the pg_wal directory, in case a standby server needs to fetch them for streaming - replication. Each segment is normally 16 megabytes. If a standby + replication. If a standby server connected to the sending server falls behind by more than - wal_keep_segments segments, the sending server might remove - a WAL segment still needed by the standby, in which case the + wal_keep_size megabytes, the sending server might + remove a WAL segment still needed by the standby, in which case the replication connection will be terminated. Downstream connections will also eventually fail as a result. (However, the standby server can recover by fetching the segment from archive, if WAL @@ -3800,14 +3800,15 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows - This sets only the minimum number of segments retained in + This sets only the minimum size of segments retained in pg_wal; the system might need to retain more segments for WAL archival or to recover from a checkpoint. If - wal_keep_segments is zero (the default), the system + wal_keep_size is zero (the default), the system doesn't keep any extra segments for standby purposes, so the number of old WAL segments available to standby servers is a function of the location of the previous checkpoint and status of WAL archiving. + If this value is specified without units, it is taken as megabytes. This parameter can only be set in the postgresql.conf file or on the server command line. diff --git a/doc/src/sgml/high-availability.sgml b/doc/src/sgml/high-availability.sgml index 6a9184f314e..89f6d6eda63 100644 --- a/doc/src/sgml/high-availability.sgml +++ b/doc/src/sgml/high-availability.sgml @@ -785,7 +785,7 @@ archive_cleanup_command = 'pg_archivecleanup /path/to/archive %r' archiving, the server might recycle old WAL segments before the standby has received them. If this occurs, the standby will need to be reinitialized from a new base backup. You can avoid this by setting - wal_keep_segments to a value large enough to ensure that + wal_keep_size to a value large enough to ensure that WAL segments are not recycled too early, or by configuring a replication slot for the standby. If you set up a WAL archive that's accessible from the standby, these solutions are not required, since the standby can @@ -929,7 +929,7 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass' In lieu of using replication slots, it is possible to prevent the removal - of old WAL segments using , or by + of old WAL segments using , or by storing the segments in an archive using . However, these methods often result in retaining more WAL segments than diff --git a/doc/src/sgml/ref/pg_basebackup.sgml b/doc/src/sgml/ref/pg_basebackup.sgml index aa41fb444fa..e246efbdb52 100644 --- a/doc/src/sgml/ref/pg_basebackup.sgml +++ b/doc/src/sgml/ref/pg_basebackup.sgml @@ -305,7 +305,7 @@ PostgreSQL documentation The write-ahead log files are collected at the end of the backup. Therefore, it is necessary for the - parameter to be set high + parameter to be set high enough that the log is not removed before the end of the backup. If the log has been rotated when it's time to transfer it, the backup will fail and be unusable. diff --git a/doc/src/sgml/wal.sgml b/doc/src/sgml/wal.sgml index 1902f36291d..7a13d8d5025 100644 --- a/doc/src/sgml/wal.sgml +++ b/doc/src/sgml/wal.sgml @@ -578,7 +578,8 @@ Independently of max_wal_size, - + 1 most recent WAL files are + the most recent megabytes of + WAL files plus one additional WAL file are kept at all times. Also, if WAL archiving is used, old segments can not be removed or recycled until they are archived. If WAL archiving cannot keep up with the pace that WAL is generated, or if archive_command -- cgit v1.2.3