From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
Subject: | pgsql: Harden postgres_fdw tests against unexpected cache flushes. |
Date: | 2023-02-27 21:30:04 |
Message-ID: | E1pWl4N-0011az-US@gemulon.postgresql.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-committers |
Harden postgres_fdw tests against unexpected cache flushes.
postgres_fdw will close its remote session if an sinval cache reset
occurs, since it's possible that that means some FDW parameters
changed. We had two tests that were trying to ensure that the
session remains alive by setting debug_discard_caches = 0; but
that's not sufficient. Even though the tests seem stable enough
in the buildfarm, they flap a lot under CI.
In the first test, which is checking the ability to recover from
a lost connection, we can stabilize the results by just not
caring whether pg_terminate_backend() finds a victim backend.
If a reset did happen, there won't be a session to terminate
anymore, but the test can proceed anyway. (Arguably, we are
then not testing the unintentional-disconnect case, but as long
as that scenario is exercised in most runs I think it's fine;
testing the reset-driven case is of value too.)
In the second test, which is trying to verify the application_name
displayed in pg_stat_activity by a remote session, we had a race
condition in that the remote session might go away before we can
fetch its pg_stat_activity entry. We can close that race and make
the test more certainly test what it intends to by arranging things
so that the remote session itself fetches its pg_stat_activity entry
(based on PID rather than a somewhat-circular assumption about the
application name).
Both tests now demonstrably pass under debug_discard_caches = 1,
so we can remove that hack.
Back-patch into relevant back branches.
Discussion: https://postgr.es/m/20230226194340.u44bkfgyz64c67i6@awork3.anarazel.de
Branch
------
REL_15_STABLE
Details
-------
https://git.postgresql.org/pg/commitdiff/bc77be7145e1dfa9296cd219a269c40b6c1d9f9d
Modified Files
--------------
contrib/postgres_fdw/expected/postgres_fdw.out | 94 +++++++++++---------------
contrib/postgres_fdw/sql/postgres_fdw.sql | 51 +++++++-------
2 files changed, 64 insertions(+), 81 deletions(-)
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2023-02-27 22:21:37 | pgsql: Suppress compiler warnings in new pgstats code. |
Previous Message | Robert Haas | 2023-02-27 16:57:04 | Re: pgsql: pg_rewind: Fix determining TLI when server was just promoted. |