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

Commitbeba3c2

Browse files
michaelpqXuneng Zhou
and
Xuneng Zhou
committed
Fix timing-dependent failure in recovery test 004_timeline_switch
The test introduced by17b2d5e verifies that a WAL receiversurvives across a timeline jump by searching the server logs fortermination messages. However, it called restart() before the timelineswitch, which kills the WAL receiver and may log the exact message beingchecked, hence failing the test. As TAP tests reuse the same log fileacross restarts, a rotate_logfile() is used before the restart so as thelog matching check is not impacted by log entries generated by aprevious shutdown.Recent changes to file handle inheritance altered I/O timing enough tomake this fail consistently while testing another patch.While on it, this adds an extra check based on a PID comparison. Thistest may lead to false positives as it could be possible that the WALreceiver has processed a timeline jump before the initial PID isgrabbed, but it should be good enough in most cases.Like17b2d5e, backpatch down to v13.Author: Bryan Green <dbryan.green@gmail.com>Co-authored-by: Xuneng Zhou <xunengzhou@gmail.com>Discussion:https://postgr.es/m/9d00b597-d64a-4f1e-802e-90f9dc394c70@gmail.comBackpatch-through: 13
1 parent0418716 commitbeba3c2

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

‎src/test/recovery/t/004_timeline_switch.pl‎

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
use File::Pathqw(rmtree);
88
use PostgresNode;
99
use TestLib;
10-
use Test::Moretests=>4;
10+
use Test::Moretests=>5;
1111

1212
$ENV{PGDATABASE} ='postgres';
1313

@@ -58,8 +58,19 @@
5858
'postgresql.conf',qq(
5959
primary_conninfo='$connstr_1'
6060
));
61+
62+
# Rotate logfile before restarting, for the log checks done below.
63+
$node_standby_2->rotate_logfile;
6164
$node_standby_2->restart;
6265

66+
# Wait for walreceiver to reconnect after the restart. We want to
67+
# verify that after reconnection, the walreceiver stays alive during
68+
# the timeline switch.
69+
$node_standby_2->poll_query_until('postgres',
70+
"SELECT EXISTS(SELECT 1 FROM pg_stat_wal_receiver)");
71+
my$wr_pid_before_switch =$node_standby_2->safe_psql('postgres',
72+
"SELECT pid FROM pg_stat_wal_receiver");
73+
6374
# Insert some data in standby 1 and check its presence in standby 2
6475
# to ensure that the timeline switch has been done.
6576
$node_standby_1->safe_psql('postgres',
@@ -80,6 +91,14 @@
8091
),
8192
'WAL receiver should not be stopped across timeline jumps');
8293

94+
# Verify that the walreceiver process stayed alive across the timeline
95+
# switch, check its PID.
96+
my$wr_pid_after_switch =$node_standby_2->safe_psql('postgres',
97+
"SELECT pid FROM pg_stat_wal_receiver");
98+
99+
is($wr_pid_before_switch,$wr_pid_after_switch,
100+
'WAL receiver PID matches across timeline jumps');
101+
83102
# Ensure that a standby is able to follow a primary on a newer timeline
84103
# when WAL archiving is enabled.
85104

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp