Dear Amit,
Thank you for reviewing! PSA new version. In this version I ran pgindent again.
> +#include "access/xlogdefs.h"
> #include "common/relpath.h"
> #include "libpq-fe.h"
>
> The above include is not required. I have removed that and made a few
> cosmetic changes in the attached.
Yes, it is not needed anymore. Firstly it was introduced to use the datatype
XLogRecPtr, but removed in recent version.
Moreover, I my colleague Hou found several problems for v40. Here is a fixed
version. Below bullets are the found issues.
* Fixed to allow XLOG_SWICH when reading the record, including the initial one.
The XLOG_SWICH may inserted after walsender exits. This is occurred when
archive_mode is set to on (or always).
* Fixed to set max_slot_wal_keep_size -1 only when the cluster is PG17+.
max_slot_wal_keep_size was introduced in PG13, so previous patch could not
upgrade from PG12 and prior.
The setting is only needed to upgrade logical slots, so it should be set only
when in PG17 and later.
* Avoid to call binary_upgrade_validate_wal_records() when the slot is invalidated.
The function raises an ERROR if the record corresponds to the given LSN.
The output is like:
```
ERROR: requested WAL segment pg_wal/000000010000000000000001 has already been removed
```
It is usual behavior but we do not want to error out here, so it was avoided.
The upgrading would fail correctly if there are invalid slots.
Best Regards,
Hayato Kuroda
FUJITSU LIMITED