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

Commit6476752

Browse files
committed
Fix race condition in recovery/t/009_twophase.pl test.
Since reducing pg_ctl's reaction time in commitc61559e, someslower buildfarm members have shown erratic failures in this test.The reason turns out to be that the test assumes synchronousreplication (because it does not provide any lag time for a committo replicate before shutting down the servers), but it had onlyenabled sync rep in one direction. The observed symptoms correspondto failure to replicate the last committed transaction in the otherdirection, which can be expected to happen if the shutdown commandis issued soon enough and we are providing no synchronous-commitguarantees.Fix that, and add a bit more paranoid state checking at the bottomof the script.Michael Paquier and myselfDiscussion:https://postgr.es/m/908.1498965681@sss.pgh.pa.us
1 parentefdb4f2 commit6476752

File tree

1 file changed

+39
-14
lines changed

1 file changed

+39
-14
lines changed

‎src/test/recovery/t/009_twophase.pl

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,25 @@
44

55
use PostgresNode;
66
use TestLib;
7-
use Test::Moretests=>17;
7+
use Test::Moretests=>20;
88

99
my$psql_out ='';
1010
my$psql_rc ='';
1111

12+
subconfigure_and_reload
13+
{
14+
my ($node,$parameter) =@_;
15+
my$name =$node->name;
16+
17+
$node->append_conf(
18+
'postgresql.conf',qq(
19+
$parameter
20+
));
21+
$node->psql('postgres',"SELECT pg_reload_conf()",
22+
stdout=> \$psql_out);
23+
is($psql_out,'t',"reload node$name with$parameter");
24+
}
25+
1226
# Set up two nodes, which will alternately be master and replication slave.
1327

1428
# Setup london node
@@ -28,15 +42,11 @@
2842
has_streaming=> 1);
2943
$node_paris->start;
3044

31-
# Switch to synchronous replication
32-
$node_london->append_conf(
33-
'postgresql.conf',qq(
34-
synchronous_standby_names = '*'
35-
));
36-
$node_london->psql('postgres',"SELECT pg_reload_conf()",
37-
stdout=> \$psql_out);
38-
is($psql_out,'t','Enable synchronous replication');
45+
# Switch to synchronous replication in both directions
46+
configure_and_reload($node_london,"synchronous_standby_names = 'paris'");
47+
configure_and_reload($node_paris,"synchronous_standby_names = 'london'");
3948

49+
# Set up nonce names for current master and slave nodes
4050
note"Initially, london is master and paris is slave";
4151
my ($cur_master,$cur_slave) = ($node_london,$node_paris);
4252
my$cur_master_name =$cur_master->name;
@@ -213,7 +223,10 @@
213223
($cur_master,$cur_slave) = ($node_paris,$node_london);
214224
$cur_master_name =$cur_master->name;
215225

216-
$psql_rc =$cur_master->psql('postgres',"COMMIT PREPARED 'xact_009_10'");
226+
# because london is not running at this point, we can't use syncrep commit
227+
# on this command
228+
$psql_rc =$cur_master->psql('postgres',
229+
"SET synchronous_commit = off; COMMIT PREPARED 'xact_009_10'");
217230
is($psql_rc,'0',"Restore of prepared transaction on promoted slave");
218231

219232
# restart old master as new slave
@@ -309,8 +322,8 @@
309322
$cur_master->psql('postgres',"COMMIT PREPARED 'xact_009_12'");
310323

311324
###############################################################################
312-
# Check for a lock conflict between prepared transaction with DDL inside and replay of
313-
# XLOG_STANDBY_LOCK wal record.
325+
# Check for a lock conflict between prepared transaction with DDL inside and
326+
#replay ofXLOG_STANDBY_LOCK wal record.
314327
###############################################################################
315328

316329
$cur_master->psql(
@@ -327,14 +340,20 @@
327340

328341
$cur_slave->psql(
329342
'postgres',
330-
"SELECT count(*) FROMpg_prepared_xacts",
343+
"SELECT count(*) FROMt_009_tbl2",
331344
stdout=> \$psql_out);
332-
is($psql_out,'0',"Replay prepared transaction with DDL");
345+
is($psql_out,'1',"Replay prepared transaction with DDL");
333346

334347
###############################################################################
335348
# Verify expected data appears on both servers.
336349
###############################################################################
337350

351+
$cur_master->psql(
352+
'postgres',
353+
"SELECT count(*) FROM pg_prepared_xacts",
354+
stdout=> \$psql_out);
355+
is($psql_out,'0',"No uncommitted prepared transactions on master");
356+
338357
$cur_master->psql(
339358
'postgres',
340359
"SELECT * FROM t_009_tbl ORDER BY id",
@@ -370,6 +389,12 @@
370389
is($psql_out,qq{27|issued to paris},
371390
"Check expected t_009_tbl2 data on master");
372391

392+
$cur_slave->psql(
393+
'postgres',
394+
"SELECT count(*) FROM pg_prepared_xacts",
395+
stdout=> \$psql_out);
396+
is($psql_out,'0',"No uncommitted prepared transactions on slave");
397+
373398
$cur_slave->psql(
374399
'postgres',
375400
"SELECT * FROM t_009_tbl ORDER BY id",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp