From 5a9ae56a5091023544619642711ad8288975ec60 Mon Sep 17 00:00:00 2001 From: Takamichi Osumi Date: Fri, 20 May 2022 12:58:05 +0000 Subject: [PATCH v1] Fix the intermittent Build-farm failures in 031_column_list.pl This patch adds several calls of wait_for_catchup() before each call of ALTER SUBSCRIPTION ... SET PUBLICATION in the tests. It makes both the publisher and subscriber in sync, so as not to point to a location prior to where already-created publication and then to ensure new publications visible to the WALSender. Reported-by: Peter Smith Suggested-by: Amit Kapila Author: Takamichi Osumi Discussion : https://www.postgresql.org/message-id/CAHut%2BPvMbCsL8PAz1Qc6LNoL0Ag0y3YJtPVJ8V0xVXJOPb%2B0xw%40mail.gmail.com --- src/test/subscription/t/031_column_list.pl | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/test/subscription/t/031_column_list.pl b/src/test/subscription/t/031_column_list.pl index 19812e1..f5c5890 100644 --- a/src/test/subscription/t/031_column_list.pl +++ b/src/test/subscription/t/031_column_list.pl @@ -379,6 +379,8 @@ $node_subscriber->safe_psql( CREATE TABLE tab5 (a int PRIMARY KEY, b int, d int); )); +$node_publisher->wait_for_catchup('sub1'); + $node_subscriber->safe_psql( 'postgres', qq( ALTER SUBSCRIPTION sub1 SET PUBLICATION pub2, pub3 @@ -453,6 +455,8 @@ $node_subscriber->safe_psql( CREATE TABLE tab6 (a int PRIMARY KEY, b int, c int, d int); )); +$node_publisher->wait_for_catchup('sub1'); + $node_subscriber->safe_psql( 'postgres', qq( ALTER SUBSCRIPTION sub1 SET PUBLICATION pub4 @@ -529,6 +533,8 @@ $node_subscriber->safe_psql( CREATE TABLE tab7 (a int PRIMARY KEY, b int, c int, d int); )); +$node_publisher->wait_for_catchup('sub1'); + $node_subscriber->safe_psql( 'postgres', qq( ALTER SUBSCRIPTION sub1 SET PUBLICATION pub5 @@ -645,6 +651,8 @@ $node_publisher->safe_psql( ALTER PUBLICATION pub6 ADD TABLE test_part_a_2 (b); )); +$node_publisher->wait_for_catchup('sub1'); + # add the publication to our subscription, wait for sync to complete $node_subscriber->safe_psql( 'postgres', qq( @@ -711,6 +719,8 @@ $node_publisher->safe_psql( CREATE PUBLICATION pub7 FOR TABLE test_part_b (a, b) WITH (publish_via_partition_root = true); )); +$node_publisher->wait_for_catchup('sub1'); + # add the publication to our subscription, wait for sync to complete $node_subscriber->safe_psql( 'postgres', qq( @@ -879,6 +889,8 @@ $node_publisher->safe_psql( CREATE PUBLICATION pub9 FOR TABLE test_part_d (a) WITH (publish_via_partition_root = true); )); +$node_publisher->wait_for_catchup('sub1'); + # add the publication to our subscription, wait for sync to complete $node_subscriber->safe_psql( 'postgres', qq( @@ -914,6 +926,8 @@ $node_publisher->safe_psql( INSERT INTO test_mix_1 VALUES (1, 2, 3); )); +$node_publisher->wait_for_catchup('sub1'); + $node_subscriber->safe_psql( 'postgres', qq( CREATE TABLE test_mix_1 (a int PRIMARY KEY, b int, c int); @@ -957,6 +971,8 @@ $node_publisher->safe_psql( INSERT INTO test_mix_2 VALUES (1, 2, 3); )); +$node_publisher->wait_for_catchup('sub1'); + $node_subscriber->safe_psql( 'postgres', qq( CREATE TABLE test_mix_2 (a int PRIMARY KEY, b int, c int); @@ -1092,6 +1108,8 @@ $node_publisher->safe_psql( INSERT INTO s1.t VALUES (1, 2, 3); )); +$node_publisher->wait_for_catchup('sub1'); + $node_subscriber->safe_psql( 'postgres', qq( CREATE SCHEMA s1; @@ -1115,6 +1133,8 @@ is( $node_subscriber->safe_psql('postgres', "SELECT * FROM s1.t ORDER BY a"), 4|5|6), 'two publications, publishing the same relation'); +$node_publisher->wait_for_catchup('sub1'); + # Now resync the subcription, but with publications in the opposite order. # The result should be the same. @@ -1158,6 +1178,8 @@ $node_publisher->safe_psql( INSERT INTO t VALUES (1, 2, 3); )); +$node_publisher->wait_for_catchup('sub1'); + $node_subscriber->safe_psql( 'postgres', qq( DROP SCHEMA s1 CASCADE; @@ -1206,6 +1228,8 @@ $node_publisher->safe_psql( INSERT INTO t VALUES (1, 2, 3); )); +$node_publisher->wait_for_catchup('sub1'); + $node_subscriber->safe_psql( 'postgres', qq( DROP TABLE t; -- 1.8.3.1