fix_GetWalAvailability.patch
text/x-patch
Filename: fix_GetWalAvailability.patch
Type: text/x-patch
Part: 0
Message:
Re: Review for GetWALAvailability()
Patch
Format: unified
| File | + | − |
|---|---|---|
| doc/src/sgml/catalogs.sgml | 12 | 5 |
| src/backend/access/transam/xlog.c | 2 | 2 |
diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml
index 700271fd40..199053dd4a 100644
--- a/doc/src/sgml/catalogs.sgml
+++ b/doc/src/sgml/catalogs.sgml
@@ -11240,18 +11240,25 @@ SELECT * FROM pg_locks pl LEFT JOIN pg_prepared_xacts ppx
<itemizedlist>
<listitem>
<para><literal>normal</literal> means that the claimed files
- are within <varname>max_wal_size</varname>.</para>
+ are within <varname>max_wal_size</varname>. If
+ <varname>max_slot_wal_keep_size</varname> is smaller than
+ <varname>max_wal_size</varname>, this state will not appear.</para>
</listitem>
<listitem>
<para><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>.</para>
+ by <varname>wal_keep_segments</varname>.
+ </para>
</listitem>
<listitem>
- <para><literal>lost</literal> means that some WAL files are
- definitely lost and this slot cannot be used to resume replication
- anymore.</para>
+ <para>
+ <literal>lost</literal> means that some required WAL files are
+ removed and this slot is no longer usable after once disconnected
+ during this state. Note that there are cases where the state moves
+ back to reserved or normal state when all wal senders have left
+ the just removed segment before being terminated.
+ </para>
</listitem>
</itemizedlist>
The last two states are seen only when
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 55cac186dc..d1501d0cf7 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -9528,8 +9528,8 @@ GetWALAvailability(XLogRecPtr targetLSN)
/* calculate oldest segment by max_wal_size and wal_keep_segments */
XLByteToSeg(currpos, currSeg, wal_segment_size);
- keepSegs = ConvertToXSegs(Max(max_wal_size_mb, wal_keep_segments),
- wal_segment_size) + 1;
+ keepSegs = Max(ConvertToXSegs(max_wal_size_mb, wal_keep_segments),
+ wal_segment_size) + 1;
if (currSeg > keepSegs)
oldestSegMaxWalSize = currSeg - keepSegs;