On Fri, Feb 9, 2024 at 10:00 AM Zhijie Hou (Fujitsu)
<houzj.fnst@fujitsu.com> wrote:
>
> Here is the V82 patch set which includes the following changes:
>
+reserve_wal_for_local_slot(XLogRecPtr restart_lsn)
{
...
+ /*
+ * Find the oldest existing WAL segment file.
+ *
+ * Normally, we can determine it by using the last removed segment
+ * number. However, if no WAL segment files have been removed by a
+ * checkpoint since startup, we need to search for the oldest segment
+ * file currently existing in XLOGDIR.
+ */
+ oldest_segno = XLogGetLastRemovedSegno() + 1;
+
+ if (oldest_segno == 1)
+ {
+ TimeLineID cur_timeline;
+
+ GetWalRcvFlushRecPtr(NULL, &cur_timeline);
+ oldest_segno = XLogGetOldestSegno(cur_timeline);
...
...
This means that if the restart_lsn of the slot is from the prior
timeline then the standby needs to wait for longer times to sync the
slot. Ideally, it should be okay because I don't think even if
restart_lsn of the slot may be from some prior timeline than the
current flush timeline on standby, how often that case can happen?
OTOH, in the prior version patch(v80_2-0001*), we search for the
oldest segment in all possible timelines via code like:
+reserve_wal_for_local_slot(XLogRecPtr restart_lsn)
{
...
+ */
+ oldest_segno = XLogGetLastRemovedSegno() + 1;
+
+ if (oldest_segno == 1)
+ oldest_segno = XLogGetOldestSegno(0);
I don't see a problem either way as in both scenarios this is a very
rare case and doesn't seem to cause any problem but would like to know
the opinion of others.
--
With Regards,
Amit Kapila.