pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Clean up TAP tests' usage of wait_for_catchup().
Date: Sun, 16 Jan 2022 18:29:12 +0000
Message-ID: <E1n9AHA-0003zY-Cr@gemulon.postgresql.org> (raw)

Clean up TAP tests' usage of wait_for_catchup().

By default, wait_for_catchup() waits for the replication connection
to reach the primary's write LSN.  That's fine, but in an apparent
attempt to save one query round-trip, it was coded so that we
executed pg_current_wal_lsn() again during each probe query.
Thus, we presented the standby with a moving target to be reached.
(While the test script itself couldn't be causing the write LSN
to advance while it's blocked in wait_for_catchup(), it's plenty
plausible that background activity such as autovacuum is emitting
more WAL.)  That could make the test take longer than necessary,
and potentially it could mask bugs by allowing the standby to process
more WAL than a strict interpretation of the test scenario allows.
So, change wait_for_catchup() to do it "by the book", explicitly
collecting the write LSN to wait for at the outset.

Also, various call sites were instructing wait_for_catchup() to
wait for the standby to reach the primary's insert LSN rather than
its write LSN.  This also seems like a bad idea.  While in most
test scenarios those are the same, if they are different then the
inserted-but-not-yet-written WAL is not presently available to the
standby.  The test isn't doing anything to make it become so, so
again we have the potential for unwanted test delay, perhaps even
a test timeout.  (Again, background activity would be needed to
make this more than a hypothetical problem.)  Hence, change the
callers where necessary so that the wait target is always the
primary's write LSN.

While at it, simplify callers by making use of wait_for_catchup's
default arguments wherever possible (the preceding change makes
this possible in more places than it was before).  And rewrite
wait_for_catchup's documentation a bit.

Patch by me; thanks to Julien Rouhaud for review.

Discussion: https://postgr.es/m/2368336.1641843098@sss.pgh.pa.us

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/ed48e3582e8447cb9969c366e46c82a56b7608cd

Modified Files
--------------
src/bin/pg_basebackup/t/020_pg_receivewal.pl       |  2 +-
src/bin/pg_rewind/t/007_standby_source.pl          |  8 ++---
src/bin/pg_rewind/t/008_min_recovery_point.pl      |  6 ++--
src/test/perl/PostgreSQL/Test/Cluster.pm           | 38 +++++++++++-----------
src/test/recovery/t/001_stream_rep.pl              | 25 +++++++-------
src/test/recovery/t/004_timeline_switch.pl         |  9 ++---
.../recovery/t/010_logical_decoding_timelines.pl   |  3 +-
src/test/recovery/t/012_subtransactions.pl         |  9 ++---
src/test/recovery/t/015_promotion_pages.pl         |  4 +--
src/test/recovery/t/016_min_consistency.pl         |  4 +--
src/test/recovery/t/019_replslot_limit.pl          | 17 ++++------
src/test/recovery/t/021_row_visibility.pl          | 15 +++------
src/test/recovery/t/025_stuck_on_old_timeline.pl   |  3 +-
13 files changed, 59 insertions(+), 84 deletions(-)



Message-ID: <E1n9AHA-0003zY-Cr@gemulon.postgresql.org>
Permalink:  ../E1n9AHA-0003zY-Cr@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1n9AHA-0003zY-Cr@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: tgl@sss.pgh.pa.us
  Subject: Re: pgsql: Clean up TAP tests' usage of wait_for_catchup().
  In-Reply-To: <E1n9AHA-0003zY-Cr@gemulon.postgresql.org>
  References: <E1n9AHA-0003zY-Cr@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox