|
60 | 60 | "CREATE SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr application_name=$appname' PUBLICATION tap_pub, tap_pub_ins_only" |
61 | 61 | ); |
62 | 62 |
|
63 | | -# Wait for subscriber to finish initialization |
64 | | -my $caughtup_query = |
65 | | -"SELECT pg_current_wal_lsn() <= replay_lsn FROM pg_stat_replication WHERE application_name = '$appname';"; |
66 | | -$node_publisher->poll_query_until('postgres', $caughtup_query) |
67 | | - or die "Timed out while waiting for subscriber to catch up"; |
| 63 | +$node_publisher->wait_for_catchup($appname); |
68 | 64 |
|
69 | 65 | # Also wait for initial table sync to finish |
70 | 66 | my $synced_query = |
|
93 | 89 | $node_publisher->safe_psql('postgres', |
94 | 90 | "INSERT INTO tab_mixed VALUES (2, 'bar')"); |
95 | 91 |
|
96 | | -$node_publisher->poll_query_until('postgres', $caughtup_query) |
97 | | - or die "Timed out while waiting for subscriber to catch up"; |
| 92 | +$node_publisher->wait_for_catchup($appname); |
98 | 93 |
|
99 | 94 | $result = $node_subscriber->safe_psql('postgres', |
100 | 95 | "SELECT count(*), min(a), max(a) FROM tab_ins"); |
|
132 | 127 | $node_publisher->safe_psql('postgres', |
133 | 128 | "UPDATE tab_full2 SET x = 'bb' WHERE x = 'b'"); |
134 | 129 |
|
135 | | -# Wait for subscription to catch up |
136 | | -$node_publisher->poll_query_until('postgres', $caughtup_query) |
137 | | - or die "Timed out while waiting for subscriber to catch up"; |
| 130 | +$node_publisher->wait_for_catchup($appname); |
138 | 131 |
|
139 | 132 | $result = $node_subscriber->safe_psql('postgres', |
140 | 133 | "SELECT count(*), min(a), max(a) FROM tab_full"); |
|
176 | 169 | "INSERT INTO tab_ins SELECT generate_series(1001,1100)"); |
177 | 170 | $node_publisher->safe_psql('postgres', "DELETE FROM tab_rep"); |
178 | 171 |
|
179 | | -$node_publisher->poll_query_until('postgres', $caughtup_query) |
180 | | - or die "Timed out while waiting for subscriber to catch up"; |
| 172 | +$node_publisher->wait_for_catchup($appname); |
181 | 173 |
|
182 | 174 | $result = $node_subscriber->safe_psql('postgres', |
183 | 175 | "SELECT count(*), min(a), max(a) FROM tab_ins"); |
|
200 | 192 | ); |
201 | 193 | $node_publisher->safe_psql('postgres', "INSERT INTO tab_full VALUES(0)"); |
202 | 194 |
|
203 | | -$node_publisher->poll_query_until('postgres', $caughtup_query) |
204 | | - or die "Timed out while waiting for subscriber to catch up"; |
| 195 | +$node_publisher->wait_for_catchup($appname); |
205 | 196 |
|
206 | 197 | # note that data are different on provider and subscriber |
207 | 198 | $result = $node_subscriber->safe_psql('postgres', |
|
0 commit comments