pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Harden postgres_fdw tests against unexpected cache flushes. 3+ messages / 1 participants [nested] [flat]
* pgsql: Harden postgres_fdw tests against unexpected cache flushes. @ 2023-02-27 21:30 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2023-02-27 21:30 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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 ------ master Details ------- https://git.postgresql.org/pg/commitdiff/53fe7e6cb81b26218f8652f5f3fe4fece944f958 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(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Harden postgres_fdw tests against unexpected cache flushes. @ 2023-02-27 21:30 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2023-02-27 21:30 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
* pgsql: Harden postgres_fdw tests against unexpected cache flushes. @ 2023-02-27 21:30 Tom Lane <tgl@sss.pgh.pa.us> 0 siblings, 0 replies; 3+ messages in thread From: Tom Lane @ 2023-02-27 21:30 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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_14_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/ba019b4dacf637459148f1327f9345bff031dfe2 Modified Files -------------- contrib/postgres_fdw/expected/postgres_fdw.out | 26 ++++++++------------------ contrib/postgres_fdw/sql/postgres_fdw.sql | 18 ++++++++---------- 2 files changed, 16 insertions(+), 28 deletions(-) ^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~2023-02-27 21:30 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2023-02-27 21:30 pgsql: Harden postgres_fdw tests against unexpected cache flushes. Tom Lane <tgl@sss.pgh.pa.us> 2023-02-27 21:30 pgsql: Harden postgres_fdw tests against unexpected cache flushes. Tom Lane <tgl@sss.pgh.pa.us> 2023-02-27 21:30 pgsql: Harden postgres_fdw tests against unexpected cache flushes. Tom Lane <tgl@sss.pgh.pa.us>
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