Re: Add contrib/pg_logicalsnapinspect

Masahiko Sawada <sawada.mshk@gmail.com>

From: Masahiko Sawada <sawada.mshk@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>, Peter Smith <smithpb2250@gmail.com>, Peter Eisentraut <peter@eisentraut.org>, shveta malik <shveta.malik@gmail.com>, Amit Kapila <amit.kapila16@gmail.com>, Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>, pgsql-hackers@lists.postgresql.org
Date: 2025-03-05T06:25:57Z
Lists: pgsql-hackers

Commits

Same data as JSON: GET /api/v1/messages/:b64id/commits the thread's linked commits as JSON, with link sources. API reference →
  1. Fix indentation issue

  2. pg_logicalinspect: Stabilize isolation tests.

  3. Add contrib/pg_logicalinspect.

  4. Move SnapBuild and SnapBuildOnDisk structs to snapshot_internal.h.

On Tue, Mar 4, 2025 at 1:56 PM Andres Freund <andres@anarazel.de> wrote:
>
> Hi,
>
> On 2024-10-14 18:08:10 -0700, Masahiko Sawada wrote:
> > I fixed a compiler warning by -Wtypedef-redefinition related to the
> > declaration of SnapBuild struct, then pushed both patches.
>
> This just failed on skink (valgrind buildfarm animal):
> https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=skink&dt=2025-03-04%2017%3A35%3A01
>
> In the last months (not sure quite how long) only the main regression tests
> were running under valgrind. I fixed that, and in one of the runs since then
> the above regression failure was triggered.
>
> diff -U3 /home/bf/bf-build/skink-master/HEAD/pgsql/contrib/pg_logicalinspect/expected/logical_inspect.out /home/bf/bf-build/skink-master/HEAD/pgsql.build/testrun/pg_logicalinspect/isolation/results/logical_inspect.out
> --- /home/bf/bf-build/skink-master/HEAD/pgsql/contrib/pg_logicalinspect/expected/logical_inspect.out    2024-10-15 01:07:04.632684683 +0000
> +++ /home/bf/bf-build/skink-master/HEAD/pgsql.build/testrun/pg_logicalinspect/isolation/results/logical_inspect.out     2025-03-04 18:49:34.659306138 +0000
> @@ -42,11 +42,12 @@
>  ----------+---------------+----------------------+---------------+----------------------
>  consistent|              0|                      |              2|                     2
>  consistent|              2|                     2|              0|
> -(2 rows)
> +consistent|              2|                     2|              0|
> +(3 rows)
>
>  step s1_get_logical_snapshot_meta: SELECT COUNT(meta.*) from pg_ls_logicalsnapdir(), pg_get_logical_snapshot_meta(name) as meta;
>  count
>  -----
> -    2
> +    3
>  (1 row)

Thank you for the report.

It seems that bgwriter wrote another RUNNING_XACTS record during the
test, making the logical decoding write an extra snapshot on the disk.

One way to stabilize the regression test would be that we check if
there is a serialized snapshot that has expected number of catchange
transactions and number of committed transactions, instead of dumping
all serialized snapshots.

Regards,

-- 
Masahiko Sawada
Amazon Web Services: https://aws.amazon.com