Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit b6df079

Browse files
author
Amit Kapila
committed
Fix the intermittent buildfarm failures in 031_column_list.
The reason was that the ALTER SUBSCRIPTION .. SET PUBLICATION will lead to the restarting of apply worker and after the restart, the apply worker will use the existing slot and replication origin corresponding to the subscription. Now, it is possible that before restart the origin has not been updated and the WAL start location points to a location before where PUBLICATION exists which can lead to the error "publication ... does not exist". Fix it by recreating the subscription as a newly created subscription will start processing WAL from the recent WAL location and will see the required publication. This behavior has existed from the time logical replication was introduced but is exposed by this test and we have started a discussion for a better fix for this problem. As per Buildfarm Diagnosed-by: Amit Kapila Author: Vignesh C Discussion: https://postgr.es/m/3307255.1706911634@sss.pgh.pa.us
1 parent fbc93b8 commit b6df079

File tree

1 file changed

+28
-15
lines changed

1 file changed

+28
-15
lines changed

src/test/subscription/t/031_column_list.pl

+28-15
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,8 @@
370370

371371
$node_subscriber->safe_psql(
372372
'postgres', qq(
373-
ALTER SUBSCRIPTION sub1 SET PUBLICATION pub2, pub3
373+
DROP SUBSCRIPTION sub1;
374+
CREATE SUBSCRIPTION sub1 CONNECTION '$publisher_connstr' PUBLICATION pub2, pub3
374375
));
375376

376377
$node_subscriber->wait_for_subscription_sync($node_publisher, 'sub1');
@@ -411,7 +412,8 @@
411412

412413
$node_subscriber->safe_psql(
413414
'postgres', qq(
414-
ALTER SUBSCRIPTION sub1 SET PUBLICATION pub4
415+
DROP SUBSCRIPTION sub1;
416+
CREATE SUBSCRIPTION sub1 CONNECTION '$publisher_connstr' PUBLICATION pub4
415417
));
416418

417419
$node_subscriber->wait_for_subscription_sync;
@@ -487,7 +489,8 @@
487489

488490
$node_subscriber->safe_psql(
489491
'postgres', qq(
490-
ALTER SUBSCRIPTION sub1 SET PUBLICATION pub5
492+
DROP SUBSCRIPTION sub1;
493+
CREATE SUBSCRIPTION sub1 CONNECTION '$publisher_connstr' PUBLICATION pub5
491494
));
492495

493496
$node_subscriber->wait_for_subscription_sync;
@@ -601,10 +604,12 @@
601604
ALTER PUBLICATION pub6 ADD TABLE test_part_a_2 (b);
602605
));
603606

604-
# add the publication to our subscription, wait for sync to complete
607+
# create the subscription for the above publication, wait for sync to
608+
# complete
605609
$node_subscriber->safe_psql(
606610
'postgres', qq(
607-
ALTER SUBSCRIPTION sub1 SET PUBLICATION pub6
611+
DROP SUBSCRIPTION sub1;
612+
CREATE SUBSCRIPTION sub1 CONNECTION '$publisher_connstr' PUBLICATION pub6
608613
));
609614

610615
$node_subscriber->wait_for_subscription_sync;
@@ -667,10 +672,12 @@
667672
CREATE PUBLICATION pub7 FOR TABLE test_part_b (a, b) WITH (publish_via_partition_root = true);
668673
));
669674

670-
# add the publication to our subscription, wait for sync to complete
675+
# create the subscription for the above publication, wait for sync to
676+
# complete
671677
$node_subscriber->safe_psql(
672678
'postgres', qq(
673-
ALTER SUBSCRIPTION sub1 SET PUBLICATION pub7
679+
DROP SUBSCRIPTION sub1;
680+
CREATE SUBSCRIPTION sub1 CONNECTION '$publisher_connstr' PUBLICATION pub7
674681
));
675682

676683
$node_subscriber->wait_for_subscription_sync;
@@ -737,7 +744,8 @@
737744
ALTER PUBLICATION pub8 ADD TABLE test_part_c_2 (a,b);
738745
));
739746

740-
# add the publication to our subscription, wait for sync to complete
747+
# create the subscription for the above publication, wait for sync to
748+
# complete
741749
$node_subscriber->safe_psql(
742750
'postgres', qq(
743751
DROP SUBSCRIPTION sub1;
@@ -835,10 +843,12 @@
835843
CREATE PUBLICATION pub9 FOR TABLE test_part_d (a) WITH (publish_via_partition_root = true);
836844
));
837845

838-
# add the publication to our subscription, wait for sync to complete
846+
# create the subscription for the above publication, wait for sync to
847+
# complete
839848
$node_subscriber->safe_psql(
840849
'postgres', qq(
841-
ALTER SUBSCRIPTION sub1 SET PUBLICATION pub9
850+
DROP SUBSCRIPTION sub1;
851+
CREATE SUBSCRIPTION sub1 CONNECTION '$publisher_connstr' PUBLICATION pub9
842852
));
843853

844854
$node_subscriber->wait_for_subscription_sync;
@@ -880,8 +890,8 @@
880890
$node_subscriber->safe_psql(
881891
'postgres', qq(
882892
CREATE TABLE test_mix_2 (a int PRIMARY KEY, b int, c int);
883-
ALTER SUBSCRIPTION sub1 SET PUBLICATION pub_mix_3, pub_mix_4;
884-
ALTER SUBSCRIPTION sub1 REFRESH PUBLICATION;
893+
DROP SUBSCRIPTION sub1;
894+
CREATE SUBSCRIPTION sub1 CONNECTION '$publisher_connstr' PUBLICATION pub_mix_3, pub_mix_4;
885895
));
886896

887897
$node_subscriber->wait_for_subscription_sync;
@@ -1022,7 +1032,8 @@
10221032
CREATE TABLE s1.t (a int, b int, c int) PARTITION BY RANGE (a);
10231033
CREATE TABLE t_1 PARTITION OF s1.t FOR VALUES FROM (1) TO (10);
10241034
1025-
ALTER SUBSCRIPTION sub1 SET PUBLICATION pub1, pub2;
1035+
DROP SUBSCRIPTION sub1;
1036+
CREATE SUBSCRIPTION sub1 CONNECTION '$publisher_connstr' PUBLICATION pub1, pub2;
10261037
));
10271038

10281039
$node_subscriber->wait_for_subscription_sync;
@@ -1090,7 +1101,8 @@
10901101
PARTITION BY RANGE (a);
10911102
CREATE TABLE t_2 PARTITION OF t_1 FOR VALUES FROM (1) TO (10);
10921103
1093-
ALTER SUBSCRIPTION sub1 SET PUBLICATION pub3;
1104+
DROP SUBSCRIPTION sub1;
1105+
CREATE SUBSCRIPTION sub1 CONNECTION '$publisher_connstr' PUBLICATION pub3;
10941106
));
10951107

10961108
$node_subscriber->wait_for_subscription_sync;
@@ -1138,7 +1150,8 @@
11381150
PARTITION BY RANGE (a);
11391151
CREATE TABLE t_2 PARTITION OF t_1 FOR VALUES FROM (1) TO (10);
11401152
1141-
ALTER SUBSCRIPTION sub1 SET PUBLICATION pub4;
1153+
DROP SUBSCRIPTION sub1;
1154+
CREATE SUBSCRIPTION sub1 CONNECTION '$publisher_connstr' PUBLICATION pub4;
11421155
));
11431156

11441157
$node_subscriber->wait_for_subscription_sync;

0 commit comments

Comments
 (0)