|
414 | 414 | 'update works with dropped subscriber column');
|
415 | 415 |
|
416 | 416 | # check that change of connection string and/or publication list causes
|
417 |
| -# restart of subscription workers. Not all of these are registered as tests |
418 |
| -# as we need to poll for a change but the test suite will fail none the less |
419 |
| -# when something goes wrong. |
| 417 | +# restart of subscription workers. We check the state along with |
| 418 | +# application_name to ensure that the walsender is (re)started. |
| 419 | +# |
| 420 | +# Not all of these are registered as tests as we need to poll for a change |
| 421 | +# but the test suite will fail none the less when something goes wrong. |
420 | 422 | my $oldpid = $node_publisher->safe_psql('postgres',
|
421 |
| - "SELECT pid FROM pg_stat_replication WHERE application_name = 'tap_sub';" |
| 423 | + "SELECT pid FROM pg_stat_replication WHERE application_name = 'tap_sub' AND state = 'streaming';" |
422 | 424 | );
|
423 | 425 | $node_subscriber->safe_psql('postgres',
|
424 | 426 | "ALTER SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr sslmode=disable'"
|
425 | 427 | );
|
426 | 428 | $node_publisher->poll_query_until('postgres',
|
427 |
| - "SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = 'tap_sub';" |
428 |
| -) or die "Timed out while waiting for apply to restart"; |
| 429 | + "SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = 'tap_sub' AND state = 'streaming';" |
| 430 | +) or die "Timed out while waiting for apply to restart after changing CONNECTION"; |
429 | 431 |
|
430 | 432 | $oldpid = $node_publisher->safe_psql('postgres',
|
431 |
| - "SELECT pid FROM pg_stat_replication WHERE application_name = 'tap_sub';" |
| 433 | + "SELECT pid FROM pg_stat_replication WHERE application_name = 'tap_sub' AND state = 'streaming';" |
432 | 434 | );
|
433 | 435 | $node_subscriber->safe_psql('postgres',
|
434 | 436 | "ALTER SUBSCRIPTION tap_sub SET PUBLICATION tap_pub_ins_only WITH (copy_data = false)"
|
435 | 437 | );
|
436 | 438 | $node_publisher->poll_query_until('postgres',
|
437 |
| - "SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = 'tap_sub';" |
438 |
| -) or die "Timed out while waiting for apply to restart"; |
| 439 | + "SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = 'tap_sub' AND state = 'streaming';" |
| 440 | +) or die "Timed out while waiting for apply to restart after changing PUBLICATION"; |
439 | 441 |
|
440 | 442 | $node_publisher->safe_psql('postgres',
|
441 | 443 | "INSERT INTO tab_ins SELECT generate_series(1001,1100)");
|
|
483 | 485 |
|
484 | 486 | # check restart on rename
|
485 | 487 | $oldpid = $node_publisher->safe_psql('postgres',
|
486 |
| - "SELECT pid FROM pg_stat_replication WHERE application_name = 'tap_sub';" |
| 488 | + "SELECT pid FROM pg_stat_replication WHERE application_name = 'tap_sub' AND state = 'streaming';" |
487 | 489 | );
|
488 | 490 | $node_subscriber->safe_psql('postgres',
|
489 | 491 | "ALTER SUBSCRIPTION tap_sub RENAME TO tap_sub_renamed");
|
490 | 492 | $node_publisher->poll_query_until('postgres',
|
491 |
| - "SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = 'tap_sub_renamed';" |
492 |
| -) or die "Timed out while waiting for apply to restart"; |
| 493 | + "SELECT pid != $oldpid FROM pg_stat_replication WHERE application_name = 'tap_sub_renamed' AND state = 'streaming';" |
| 494 | +) or die "Timed out while waiting for apply to restart after renaming SUBSCRIPTION"; |
493 | 495 |
|
494 | 496 | # check all the cleanup
|
495 | 497 | $node_subscriber->safe_psql('postgres', "DROP SUBSCRIPTION tap_sub_renamed");
|
|
0 commit comments