mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
Allow users to limit storage reserved by replication slots
Replication slots are useful to retain data that may be needed by a replication system. But experience has shown that allowing them to retain excessive data can lead to the primary failing because of running out of space. This new feature allows the user to configure a maximum amount of space to be reserved using the new option max_slot_wal_keep_size. Slots that overrun that space are invalidated at checkpoint time, enabling the storage to be released. Author: Kyotaro HORIGUCHI <horiguchi.kyotaro@lab.ntt.co.jp> Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com> Reviewed-by: Jehan-Guillaume de Rorthais <jgdr@dalibo.com> Reviewed-by: Álvaro Herrera <alvherre@alvh.no-ip.org> Discussion: https://postgr.es/m/20170228.122736.123383594.horiguchi.kyotaro@lab.ntt.co.jp
This commit is contained in:
@ -9907,6 +9907,44 @@ SELECT * FROM pg_locks pl LEFT JOIN pg_prepared_xacts ppx
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><structfield>wal_status</structfield></entry>
|
||||
<entry><type>text</type></entry>
|
||||
<entry></entry>
|
||||
|
||||
<entry>Availability of WAL files claimed by this slot.
|
||||
Possible values are:
|
||||
<simplelist>
|
||||
<member>
|
||||
<literal>normal</literal> means that the claimed files
|
||||
are within <varname>max_wal_size</varname>
|
||||
</member>
|
||||
<member>
|
||||
<literal>reserved</literal> means that <varname>max_wal_size</varname>
|
||||
is exceeded but the files are still held, either by some replication
|
||||
slot or by <varname>wal_keep_segments</varname>
|
||||
</member>
|
||||
<member>
|
||||
<literal>lost</literal> means that some WAL files are definitely lost
|
||||
and this slot cannot be used to resume replication anymore.
|
||||
</member>
|
||||
</simplelist>
|
||||
The last two states are seen only when
|
||||
<xref linkend="guc-max-slot-wal-keep-size"/> is
|
||||
non-negative. If <structfield>restart_lsn</structfield> is NULL, this
|
||||
field is null.
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
<row>
|
||||
<entry><structfield>min_safe_lsn</structfield></entry>
|
||||
<entry><type>pg_lsn</type></entry>
|
||||
<entry></entry>
|
||||
<entry>
|
||||
The minimum LSN currently available for walsenders.
|
||||
</entry>
|
||||
</row>
|
||||
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</table>
|
||||
|
@ -3777,6 +3777,29 @@ restore_command = 'copy "C:\\server\\archivedir\\%f" "%p"' # Windows
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id="guc-max-slot-wal-keep-size" xreflabel="max_slot_wal_keep_size">
|
||||
<term><varname>max_slot_wal_keep_size</varname> (<type>integer</type>)
|
||||
<indexterm>
|
||||
<primary><varname>max_slot_wal_keep_size</varname> configuration parameter</primary>
|
||||
</indexterm>
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Specify the maximum size of WAL files
|
||||
that <link linkend="streaming-replication-slots">replication
|
||||
slots</link> are allowed to retain in the <filename>pg_wal</filename>
|
||||
directory at checkpoint time.
|
||||
If <varname>max_slot_wal_keep_size</varname> is -1 (the default),
|
||||
replication slots retain unlimited amount of WAL files. If
|
||||
restart_lsn of a replication slot gets behind more than that megabytes
|
||||
from the current LSN, the standby using the slot may no longer be able
|
||||
to continue replication due to removal of required WAL files. You
|
||||
can see the WAL availability of replication slots
|
||||
in <link linkend="view-pg-replication-slots">pg_replication_slots</link>.
|
||||
</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
|
||||
<varlistentry id="guc-wal-sender-timeout" xreflabel="wal_sender_timeout">
|
||||
<term><varname>wal_sender_timeout</varname> (<type>integer</type>)
|
||||
<indexterm>
|
||||
|
@ -925,9 +925,11 @@ primary_conninfo = 'host=192.168.1.50 port=5432 user=foo password=foopass'
|
||||
<xref linkend="guc-archive-command"/>.
|
||||
However, these methods often result in retaining more WAL segments than
|
||||
required, whereas replication slots retain only the number of segments
|
||||
known to be needed. An advantage of these methods is that they bound
|
||||
the space requirement for <literal>pg_wal</literal>; there is currently no way
|
||||
to do this using replication slots.
|
||||
known to be needed. On the other hand, replication slots can retain so
|
||||
many WAL segments that they fill up the space allocated
|
||||
for <literal>pg_wal</literal>;
|
||||
<xref linkend="guc-max-slot-wal-keep-size"/> limits the size of WAL files
|
||||
retained by replication slots.
|
||||
</para>
|
||||
<para>
|
||||
Similarly, <xref linkend="guc-hot-standby-feedback"/>
|
||||
|
Reference in New Issue
Block a user