Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8d0138e

Browse files
author
Amit Kapila
committed
Fix the random test failure in 001_rep_changes.
The check to test whether the subscription workers were restarting after achange in the subscription was failing. The reason was that the test wasassuming the walsender started before it reaches the 'streaming' state andthe walsender was exiting due to an error before that. Now, the walsenderwas erroring out before reaching the 'streaming' state because it tries toacquire the slot before the previous walsender has exited.In passing, improve the die messages so that it is easier to investigatethe failures in the future if any.Reported-by: Michael Paquier, as per buildfarmAuthor: Ajin CherianReviewed-by: Masahiko Sawada, Amit KapilaBackpatch-through: 10, where this test was introducedDiscussion:https://postgr.es/m/YRnhFxa9bo73wfpV@paquier.xyz
1 parentb175b9c commit8d0138e

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

‎src/test/subscription/t/001_rep_changes.pl

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -414,28 +414,30 @@
414414
'update works with dropped subscriber column');
415415

416416
# 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.
420422
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';"
422424
);
423425
$node_subscriber->safe_psql('postgres',
424426
"ALTER SUBSCRIPTION tap_sub CONNECTION '$publisher_connstr sslmode=disable'"
425427
);
426428
$node_publisher->poll_query_until('postgres',
427-
"SELECT pid !=$oldpid FROM pg_stat_replication WHERE application_name = 'tap_sub';"
428-
)ordie"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+
)ordie"Timed out while waiting for apply to restart after changing CONNECTION";
429431

430432
$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';"
432434
);
433435
$node_subscriber->safe_psql('postgres',
434436
"ALTER SUBSCRIPTION tap_sub SET PUBLICATION tap_pub_ins_only WITH (copy_data = false)"
435437
);
436438
$node_publisher->poll_query_until('postgres',
437-
"SELECT pid !=$oldpid FROM pg_stat_replication WHERE application_name = 'tap_sub';"
438-
)ordie"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+
)ordie"Timed out while waiting for apply to restart after changing PUBLICATION";
439441

440442
$node_publisher->safe_psql('postgres',
441443
"INSERT INTO tab_ins SELECT generate_series(1001,1100)");
@@ -483,13 +485,13 @@
483485

484486
# check restart on rename
485487
$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';"
487489
);
488490
$node_subscriber->safe_psql('postgres',
489491
"ALTER SUBSCRIPTION tap_sub RENAME TO tap_sub_renamed");
490492
$node_publisher->poll_query_until('postgres',
491-
"SELECT pid !=$oldpid FROM pg_stat_replication WHERE application_name = 'tap_sub_renamed';"
492-
)ordie"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+
)ordie"Timed out while waiting for apply to restart after renaming SUBSCRIPTION";
493495

494496
# check all the cleanup
495497
$node_subscriber->safe_psql('postgres',"DROP SUBSCRIPTION tap_sub_renamed");

‎src/test/subscription/t/022_twophase_cascade.pl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,10 @@
235235

236236
my$oldpid_B =$node_A->safe_psql('postgres',"
237237
SELECT pid FROM pg_stat_replication
238-
WHERE application_name = '$appname_B';");
238+
WHERE application_name = '$appname_B' AND state = 'streaming';");
239239
my$oldpid_C =$node_B->safe_psql('postgres',"
240240
SELECT pid FROM pg_stat_replication
241-
WHERE application_name = '$appname_C';");
241+
WHERE application_name = '$appname_C' AND state = 'streaming';");
242242

243243
# Setup logical replication (streaming = on)
244244

@@ -253,11 +253,11 @@
253253

254254
$node_A->poll_query_until('postgres',"
255255
SELECT pid !=$oldpid_B FROM pg_stat_replication
256-
WHERE application_name = '$appname_B';"
256+
WHERE application_name = '$appname_B' AND state = 'streaming';"
257257
)ordie"Timed out while waiting for apply to restart";
258258
$node_B->poll_query_until('postgres',"
259259
SELECT pid !=$oldpid_C FROM pg_stat_replication
260-
WHERE application_name = '$appname_C';"
260+
WHERE application_name = '$appname_C' AND state = 'streaming';"
261261
)ordie"Timed out while waiting for apply to restart";
262262

263263
###############################

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp