On Fri, Mar 11, 2022 at 8:22 AM Kyotaro Horiguchi <horikyota....@gmail.com> wrote: > > > - The difference between pg_get_wal_record_info and _records_ other than > - the number of argument is the former accepts incorrect LSNs. > > The discussion is somewhat confused after some twists and turns.. It > should be something like the following. > > pg_get_wal_record_info and pg_get_wal_records_info are almost same > since the latter can show a single record. However it is a bit > annoying to do that. Since, other than it doens't accept same LSNs for > start and end, it doesn't show a record when there' no record in the > specfied LSN range. But I don't think there's no usefulness of the > behavior.
I would like to reassert the usability of pg_get_wal_record_info and pg_get_wal_records_info: pg_get_wal_record_info(lsn): if lsn is invalid i.e. '0/0' - throws an error if lsn is future lsn - throws an error if lsn looks okay, it figures out the next available valid WAL record and returns info about that pg_get_wal_records_info(start_lsn, end_lsn default null) -> if start and end lsns are provided no end_lsn would give the WAL records info till the end of WAL, if start_lsn is invalid i.e. '0/0' - throws an error if start_lsn is future lsn - throws an error if end_lsn isn't provided by the user - calculates the end_lsn as server's current flush lsn if end_lsn is provided by the user - throws an error if it's future LSN if start_lsn and end_lsn look okay, it returns info about all WAL records from the next available valid WAL record of start_lsn until end_lsn So, both pg_get_wal_record_info and pg_get_wal_records_info are necessary IMHO. Coming to the behaviour when input lsn is '0/1000000', it's an issue with XLogSegmentOffset(lsn, wal_segment_size) != 0 check, which I will fix in the next version. if (*first_record != lsn && XLogSegmentOffset(lsn, wal_segment_size) != 0) ereport(WARNING, (errmsg_plural("first record is after %X/%X, at %X/%X, skipping over %u byte", "first record is after %X/%X, at %X/%X, skipping over %u bytes", (*first_record - lsn), LSN_FORMAT_ARGS(lsn), LSN_FORMAT_ARGS(*first_record), (uint32) (*first_record - lsn)))); Regards, Bharath Rupireddy.