From 0dda85366844bb48157980992f47d19a68152537 Mon Sep 17 00:00:00 2001 From: Nik Samokhvalov Date: Tue, 22 Sep 2026 11:32:09 -0700 Subject: [PATCH] isolationtester: test connection loss with an active blocker Wait for the terminated backend to exit before releasing the notice blocker. This makes the missing-error case exercise retaining a connection error across scheduler retries. --- .../expected/wait_cleanup.out | 19 ++++++++++--------- .../expected/wait_cleanup_1.out | 17 +++++++++-------- .../injection_points/specs/wait_cleanup.spec | 16 ++++++++++------ 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/src/test/modules/injection_points/expected/wait_cleanup.out b/src/test/modules/injection_points/expected/wait_cleanup.out index c5be17428fc..9c60ecfb2d4 100644 --- a/src/test/modules/injection_points/expected/wait_cleanup.out +++ b/src/test/modules/injection_points/expected/wait_cleanup.out @@ -41,7 +41,7 @@ injection_points_detach (1 row) -starting permutation: wait1 terminate3 noop3 wait2 wakeup3 noop2 detach3 +starting permutation: wait1 terminate3 noop3 release3 wait2 wakeup3 noop2 detach3 injection_points_attach ----------------------- @@ -49,22 +49,23 @@ injection_points_attach step wait1: SELECT injection_points_run('injection-points-wait'); step terminate3: - SELECT pg_terminate_backend(pid) FROM pg_stat_activity + SELECT pg_terminate_backend(pid, 180000) FROM pg_stat_activity WHERE wait_event = 'injection-points-wait'; - -step wait1: <... completed> -FATAL: terminating connection due to administrator command -server closed the connection unexpectedly - This probably means the server terminated abnormally - before or while processing the request. -step terminate3: <... completed> pg_terminate_backend -------------------- t (1 row) step noop3: +s3: NOTICE: release wait1 +step release3: DO $$BEGIN RAISE NOTICE 'release wait1'; END$$; +step wait1: <... completed> +FATAL: terminating connection due to administrator command +server closed the connection unexpectedly + This probably means the server terminated abnormally + before or while processing the request. + step wait2: SELECT injection_points_run('injection-points-wait'); step wakeup3: SELECT injection_points_wakeup('injection-points-wait'); injection_points_wakeup diff --git a/src/test/modules/injection_points/expected/wait_cleanup_1.out b/src/test/modules/injection_points/expected/wait_cleanup_1.out index 516a428b364..71ae751cbee 100644 --- a/src/test/modules/injection_points/expected/wait_cleanup_1.out +++ b/src/test/modules/injection_points/expected/wait_cleanup_1.out @@ -41,7 +41,7 @@ injection_points_detach (1 row) -starting permutation: wait1 terminate3 noop3 wait2 wakeup3 noop2 detach3 +starting permutation: wait1 terminate3 noop3 release3 wait2 wakeup3 noop2 detach3 injection_points_attach ----------------------- @@ -49,21 +49,22 @@ injection_points_attach step wait1: SELECT injection_points_run('injection-points-wait'); step terminate3: - SELECT pg_terminate_backend(pid) FROM pg_stat_activity + SELECT pg_terminate_backend(pid, 180000) FROM pg_stat_activity WHERE wait_event = 'injection-points-wait'; - -step wait1: <... completed> -server closed the connection unexpectedly - This probably means the server terminated abnormally - before or while processing the request. -step terminate3: <... completed> pg_terminate_backend -------------------- t (1 row) step noop3: +s3: NOTICE: release wait1 +step release3: DO $$BEGIN RAISE NOTICE 'release wait1'; END$$; +step wait1: <... completed> +server closed the connection unexpectedly + This probably means the server terminated abnormally + before or while processing the request. + step wait2: SELECT injection_points_run('injection-points-wait'); step wakeup3: SELECT injection_points_wakeup('injection-points-wait'); injection_points_wakeup diff --git a/src/test/modules/injection_points/specs/wait_cleanup.spec b/src/test/modules/injection_points/specs/wait_cleanup.spec index ed7d21c4de4..fa482f2422c 100644 --- a/src/test/modules/injection_points/specs/wait_cleanup.spec +++ b/src/test/modules/injection_points/specs/wait_cleanup.spec @@ -26,9 +26,9 @@ session s2 step wait2 { SELECT injection_points_run('injection-points-wait'); } step noop2 { } -# Control session. The blocker annotations on cancel3/terminate3, -# together with noop3, make the tester wait until wait1 has fully -# completed before starting wait2. Otherwise, wait2 could register a +# Control session. The blocker on cancel3 and the notice from release3 +# make the tester wait until wait1 has fully completed before starting +# wait2. Otherwise, wait2 could register a # new waiter slot while s1 still owns the previous one. session s3 step cancel3 { @@ -36,15 +36,19 @@ step cancel3 { WHERE wait_event = 'injection-points-wait'; } step terminate3 { - SELECT pg_terminate_backend(pid) FROM pg_stat_activity + SELECT pg_terminate_backend(pid, 180000) FROM pg_stat_activity WHERE wait_event = 'injection-points-wait'; } step wakeup3 { SELECT injection_points_wakeup('injection-points-wait'); } step detach3 { SELECT injection_points_detach('injection-points-wait'); } +step release3 { DO $$BEGIN RAISE NOTICE 'release wait1'; END$$; } step noop3 { } permutation wait1 cancel3(wait1) noop3 wait2 wakeup3 noop2 detach3 # The terminate permutation has to stay last: s1's connection is dead -# afterwards, and the tester never reconnects a session. -permutation wait1 terminate3(wait1) noop3 wait2 wakeup3 noop2 detach3 +# afterwards, and the tester never reconnects a session. Delay reporting +# wait1 until release3 sends its notice, even if the connection is already +# closed, to exercise retaining the connection error across step retries. +# terminate3 waits for backend exit before the notice blocker is released. +permutation wait1(release3 notices 1) terminate3 noop3 release3 wait2 wakeup3 noop2 detach3 -- 2.50.1 (Apple Git-155)