From f78bc4bb91563675047c7a817804ad61ac89a953 Mon Sep 17 00:00:00 2001 From: Ajin Cherian Date: Fri, 27 Aug 2021 06:53:33 -0400 Subject: [PATCH v1] fix for tap test failure seen in 001_rep_changes When a walsender restarts, the new walsender might start before the previous walsender relinquishes the slot. This will cause the new walsender to fail to acquire the slot and fail immediately. This can cause the script to wrongly assume that the new walsender has started. Then when the script tries to get the pid of the walsender and gets a NULL , further queries will fail with an error and the test fails. This fix adds a check to confirm that the new walsender reaches a 'streaming' state before continuing. --- src/test/subscription/t/001_rep_changes.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/subscription/t/001_rep_changes.pl b/src/test/subscription/t/001_rep_changes.pl index 0680f44..0b61d39 100644 --- a/src/test/subscription/t/001_rep_changes.pl +++ b/src/test/subscription/t/001_rep_changes.pl @@ -265,7 +265,7 @@ $node_subscriber->safe_psql('postgres', "ALTER SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr sslmode=disable'" ); $node_publisher->poll_query_until('postgres', - "SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = 'tap_sub';" + "SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = 'tap_sub' AND state = 'streaming';" ) or die "Timed out while waiting for apply to restart"; $oldpid = $node_publisher->safe_psql('postgres', @@ -275,7 +275,7 @@ $node_subscriber->safe_psql('postgres', "ALTER SUBSCRIPTION tap_sub SET PUBLICATION tap_pub_ins_only WITH (copy_data = false)" ); $node_publisher->poll_query_until('postgres', - "SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = 'tap_sub';" + "SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = 'tap_sub' AND state = 'streaming';" ) or die "Timed out while waiting for apply to restart"; $node_publisher->safe_psql('postgres', @@ -329,7 +329,7 @@ $oldpid = $node_publisher->safe_psql('postgres', $node_subscriber->safe_psql('postgres', "ALTER SUBSCRIPTION tap_sub RENAME TO tap_sub_renamed"); $node_publisher->poll_query_until('postgres', - "SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = 'tap_sub_renamed';" + "SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = 'tap_sub_renamed' AND state = 'streaming';" ) or die "Timed out while waiting for apply to restart"; # check all the cleanup -- 1.8.3.1