Subject: pgsql: Add contrib/pg_walinspect.

From: Jeff Davis <[email-masked]>
Date: Fri, 08 Apr 2022 07:27:44 +0000

Add contrib/pg_walinspect.

Provides similar functionality to pg_waldump, but from a SQL interface
rather than a separate utility.

Author: Bharath Rupireddy
Reviewed-by: Greg Stark, Kyotaro Horiguchi, Andres Freund, Ashutosh Sharma, Nitin Jadhav, RKN Sai Krishna
Discussion: https://postgr.es/m/CALj2ACUGUYXsEQdKhEdsBzhGEyF3xggvLdD8C0VT72TNEfOiog%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/2258e76f90bf0254504644df0515cddc0c0a87f9

Modified Files
--------------
contrib/Makefile                                 |   1 +
contrib/pg_walinspect/.gitignore                 |   4 +
contrib/pg_walinspect/Makefile                   |  23 +
contrib/pg_walinspect/expected/pg_walinspect.out | 165 ++++++
contrib/pg_walinspect/pg_walinspect--1.0.sql     | 118 +++++
contrib/pg_walinspect/pg_walinspect.c            | 629 +++++++++++++++++++++++
contrib/pg_walinspect/pg_walinspect.control      |   5 +
contrib/pg_walinspect/sql/pg_walinspect.sql      | 120 +++++
doc/src/sgml/contrib.sgml                        |   1 +
doc/src/sgml/filelist.sgml                       |   1 +
doc/src/sgml/func.sgml                           |   2 +-
doc/src/sgml/pgwalinspect.sgml                   | 275 ++++++++++
src/backend/access/rmgrdesc/xlogdesc.c           | 130 +++++
src/backend/access/transam/Makefile              |   1 +
src/backend/access/transam/xlogreader.c          |   9 -
src/backend/access/transam/xlogstats.c           |  93 ++++
src/backend/access/transam/xlogutils.c           |  33 ++
src/bin/pg_waldump/.gitignore                    |   1 +
src/bin/pg_waldump/Makefile                      |   8 +-
src/bin/pg_waldump/pg_waldump.c                  | 206 +-------
src/include/access/xlog.h                        |   2 +-
src/include/access/xlog_internal.h               |   6 +-
src/include/access/xlogreader.h                  |   2 -
src/include/access/xlogstats.h                   |  40 ++
src/include/access/xlogutils.h                   |   4 +
25 files changed, 1675 insertions(+), 204 deletions(-)

---

From: Michael Paquier <[email-masked]>
Date: Tue, 26 Apr 2022 14:13:31 +0900

Hi Jeff,

> rather than a separate utility.

The tests of pg_walinspect look unstable:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=topminnow&dt=2022-04-25%2001%3A48%3A47

 SELECT COUNT(*) >= 0 AS ok FROM
 pg_get_wal_records_info_till_end_of_wal(:'wal_lsn1');
- ok
-----
- t
-(1 row)
-
+ERROR:  could not read WAL at 0/1903E40

This points out at ReadNextXLogRecord(), though I would not blame this
test suite as you create a physical replication slot beforehand.
Could this be an issue related to the addition of the circular WAL
decoding buffer, aka 3f1ce97?

I am adding an open item about that.

Thanks,
--
Michael

---

From: Tom Lane <[email-masked]>
Date: Tue, 26 Apr 2022 01:25:14 -0400

> decoding buffer, aka 3f1ce97?

I already whined about this at [1].

I've been wondering if the issue could be traced to topminnow's unusual
hardware properties, specifically that it has MAXALIGN 8 even though
it's only a 32-bit machine per sizeof(void *).  I think the only
other active buildfarm animal like that is my gaur ... but I've
failed to reproduce it on gaur.  Best guess at the moment is that
it's a timing issue that topminnow manages to reproduce often.

Anyway, as I said in the other thread, I can reproduce it on
topminnow's host.  Let me know if you have ideas about how to
home in on the cause.

			regards, tom lane

[1] https://www.postgresql.org/message-id/111657.1650910309%40sss.pgh.pa.us

---

From: Michael Paquier <[email-masked]>
Date: Tue, 26 Apr 2022 14:36:05 +0900

> it's a timing issue that topminnow manages to reproduce often.

I have managed to miss your message.  Let's continue the discussion
there, then.

> topminnow's host.  Let me know if you have ideas about how to

Nice.  I have not been able to do so, but based on the lack of
reports from the buildfarm, that's not surprising.
--
Michael