From 8c77f41aa2a18e886294ef09460303071e413a03 Mon Sep 17 00:00:00 2001
From: Vigneshwaran C <vignesh21@gmail.com>
Date: Thu, 8 Sep 2022 09:11:18 +0530
Subject: [PATCH] Fix buildfarm tap test failure.

Drop table fails with "could not drop relation mapping", drop table
fails because relation was in "synchronized" state but drop table
expects the relation to be in "ready" state. Wait for table to be in
ready state before dropping the table.
---
 src/test/subscription/t/030_origin.pl | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/test/subscription/t/030_origin.pl b/src/test/subscription/t/030_origin.pl
index 0a5cc4503b..9125e29dbb 100644
--- a/src/test/subscription/t/030_origin.pl
+++ b/src/test/subscription/t/030_origin.pl
@@ -195,7 +195,13 @@ like(
 	"Refresh publication when the publisher has subscribed for the new table, but the subscriber-side wants origin = none"
 );
 
-$node_A->wait_for_subscription_sync($node_B, $subname_AB2);
+# Also wait for initial table sync to finish
+my $synced_query =
+  "SELECT count(1) = 0 FROM pg_subscription_rel WHERE srsubstate NOT IN ('r');";
+$node_A->poll_query_until('postgres', $synced_query)
+  or die "Timed out while waiting for subscriber to synchronize data";
+
+$node_B->wait_for_catchup($subname_AB2);
 
 # clear the operations done by this test
 $node_A->safe_psql('postgres', "DROP TABLE tab_new");
-- 
2.32.0

