Use correct LSN for error reporting in pg_walinspect
authorJeff Davis <[email protected]>
Thu, 18 Aug 2022 21:23:59 +0000 (14:23 -0700)
committerJeff Davis <[email protected]>
Thu, 18 Aug 2022 21:23:59 +0000 (14:23 -0700)
commit72af71aad9ce541ecea67ceaa7961ca39f89f227
tree0ee234db0a6495102ea5c929d3c0301e9d963ed7
parent2a42c1c51d15f8848d81739d6417376808597045
Use correct LSN for error reporting in pg_walinspect

Usage of ReadNextXLogRecord()'s first_record parameter for error
reporting isn't always correct. For instance, in GetWALRecordsInfo()
and GetWalStats(), we're reading multiple records, and first_record
is always passed as the LSN of the first record which is then used
for error reporting for later WAL record read failures. This isn't
correct.

The correct parameter to use for error reports in case of WAL
reading failures is xlogreader->EndRecPtr. This change fixes it.

While on it, removed an unnecessary Assert in pg_walinspect code.

Reported-by: Robert Haas
Author: Bharath Rupireddy
Reviewed-by: Robert Haas
Discussion: https://www.postgresql.org/message-id/CA%2BTgmoZAOGzPUifrcZRjFZ2vbtcw3mp-mN6UgEoEcQg6bY3OVg%40mail.gmail.com
Backpatch-through: 15
contrib/pg_walinspect/pg_walinspect.c