|
255 | 255 | 'update works with dropped subscriber column');
|
256 | 256 |
|
257 | 257 | # check that change of connection string and/or publication list causes
|
258 |
| -# restart of subscription workers. Not all of these are registered as tests |
259 |
| -# as we need to poll for a change but the test suite will fail none the less |
260 |
| -# when something goes wrong. |
| 258 | +# restart of subscription workers. We check the state along with |
| 259 | +# application_name to ensure that the walsender is (re)started. |
| 260 | +# |
| 261 | +# Not all of these are registered as tests as we need to poll for a change |
| 262 | +# but the test suite will fail none the less when something goes wrong. |
261 | 263 | my $oldpid = $node_publisher->safe_psql('postgres',
|
262 |
| - "SELECT pid FROM pg_stat_replication WHERE application_name = 'tap_sub';" |
| 264 | + "SELECT pid FROM pg_stat_replication WHERE application_name = 'tap_sub' AND state = 'streaming';" |
263 | 265 | );
|
264 | 266 | $node_subscriber->safe_psql('postgres',
|
265 | 267 | "ALTER SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr sslmode=disable'"
|
266 | 268 | );
|
267 | 269 | $node_publisher->poll_query_until('postgres',
|
268 |
| - "SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = 'tap_sub';" |
269 |
| -) or die "Timed out while waiting for apply to restart"; |
| 270 | + "SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = 'tap_sub' AND state = 'streaming';" |
| 271 | +) or die "Timed out while waiting for apply to restart after changing CONNECTION"; |
270 | 272 |
|
271 | 273 | $oldpid = $node_publisher->safe_psql('postgres',
|
272 |
| - "SELECT pid FROM pg_stat_replication WHERE application_name = 'tap_sub';" |
| 274 | + "SELECT pid FROM pg_stat_replication WHERE application_name = 'tap_sub' AND state = 'streaming';" |
273 | 275 | );
|
274 | 276 | $node_subscriber->safe_psql('postgres',
|
275 | 277 | "ALTER SUBSCRIPTION tap_sub SET PUBLICATION tap_pub_ins_only WITH (copy_data = false)"
|
276 | 278 | );
|
277 | 279 | $node_publisher->poll_query_until('postgres',
|
278 |
| - "SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = 'tap_sub';" |
279 |
| -) or die "Timed out while waiting for apply to restart"; |
| 280 | + "SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = 'tap_sub' AND state = 'streaming';" |
| 281 | +) or die "Timed out while waiting for apply to restart after changing PUBLICATION"; |
280 | 282 |
|
281 | 283 | $node_publisher->safe_psql('postgres',
|
282 | 284 | "INSERT INTO tab_ins SELECT generate_series(1001,1100)");
|
|
324 | 326 |
|
325 | 327 | # check restart on rename
|
326 | 328 | $oldpid = $node_publisher->safe_psql('postgres',
|
327 |
| - "SELECT pid FROM pg_stat_replication WHERE application_name = 'tap_sub';" |
| 329 | + "SELECT pid FROM pg_stat_replication WHERE application_name = 'tap_sub' AND state = 'streaming';" |
328 | 330 | );
|
329 | 331 | $node_subscriber->safe_psql('postgres',
|
330 | 332 | "ALTER SUBSCRIPTION tap_sub RENAME TO tap_sub_renamed");
|
331 | 333 | $node_publisher->poll_query_until('postgres',
|
332 |
| - "SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = 'tap_sub_renamed';" |
333 |
| -) or die "Timed out while waiting for apply to restart"; |
| 334 | + "SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = 'tap_sub_renamed' AND state = 'streaming';" |
| 335 | +) or die "Timed out while waiting for apply to restart after renaming SUBSCRIPTION"; |
334 | 336 |
|
335 | 337 | # check all the cleanup
|
336 | 338 | $node_subscriber->safe_psql('postgres', "DROP SUBSCRIPTION tap_sub_renamed");
|
|
0 commit comments