@@ -40,6 +40,8 @@ sub PostgresNode::psql_fails {
40
40
) );
41
41
$node_master -> restart;
42
42
43
+ my $psql_out = ' ' ;
44
+
43
45
# ##############################################################################
44
46
# Check that we can commit and abort after soft restart.
45
47
# Here checkpoint happens before shutdown and no WAL replay will not occur
@@ -116,6 +118,7 @@ sub PostgresNode::psql_fails {
116
118
-- didn't cleanup proc, gxact and locks on commit.
117
119
prepare transaction 'x';" ,
118
120
" Check that WAL replay will cleanup it's memory state" );
121
+ $node_master -> psql(' postgres' , " commit prepared 'x'" );
119
122
120
123
# ##############################################################################
121
124
# Check that we can commit while running active sync slave and that there is no
@@ -128,8 +131,8 @@ sub PostgresNode::psql_fails {
128
131
prepare transaction 'x';
129
132
commit prepared 'x';
130
133
" );
131
- my $result = $ node_slave-> psql(' postgres' , " select * from pg_prepared_xacts;" );
132
- is($result , " " , " Check that WAL replay will cleanup it's memory state on slave" );
134
+ $ node_slave-> psql(' postgres' , " select count(*) from pg_prepared_xacts;" , stdout => \ $psql_out );
135
+ is($psql_out , ' 0 ' , " Check that WAL replay will cleanup it's memory state on slave" );
133
136
134
137
# ##############################################################################
135
138
# The same as in previous case, but let's force checkpoint on slave between
@@ -143,8 +146,8 @@ sub PostgresNode::psql_fails {
143
146
" );
144
147
$node_slave -> psql(' postgres' ," checkpoint;" );
145
148
$node_master -> psql(' postgres' , " commit prepared 'x';" );
146
- $result = $ node_slave-> psql(' postgres' , " select * from pg_prepared_xacts;" );
147
- is($result , " " , " Check that WAL replay will cleanup it's memory state on slave after checkpoint" );
149
+ $node_slave -> psql(' postgres' , " select count(*) from pg_prepared_xacts;" , stdout => \ $psql_out );
150
+ is($psql_out , ' 0 ' , " Check that WAL replay will cleanup it's memory state on slave after checkpoint" );
148
151
149
152
# ##############################################################################
150
153
# Check that we can commit transaction on promoted slave.
@@ -183,8 +186,8 @@ sub PostgresNode::psql_fails {
183
186
$node_slave -> restart;
184
187
$node_slave -> promote;
185
188
$node_slave -> poll_query_until(' postgres' , " SELECT pg_is_in_recovery() <> true" );
186
- my $prepared_count = $ node_slave-> psql(' postgres' ," select count(*) from pg_prepared_xacts" );
187
- is($prepared_count , ' 1' , " Check that we restore prepared xacts after slave soft restart while master is down." );
189
+ $ node_slave-> psql(' postgres' ," select count(*) from pg_prepared_xacts" , stdout => \ $psql_out );
190
+ is($psql_out , ' 1' , " Check that we restore prepared xacts after slave soft restart while master is down." );
188
191
189
192
# restore state
190
193
($node_master , $node_slave ) = ($node_slave , $node_master );
@@ -210,8 +213,8 @@ sub PostgresNode::psql_fails {
210
213
$node_slave -> start;
211
214
$node_slave -> promote;
212
215
$node_slave -> poll_query_until(' postgres' , " SELECT pg_is_in_recovery() <> true" );
213
- $prepared_count = $ node_slave-> psql(' postgres' ," select count(*) from pg_prepared_xacts" );
214
- is($prepared_count , ' 1' , " Check that we restore prepared xacts after slave hard restart while master is down." );
216
+ $node_slave -> psql(' postgres' ," select count(*) from pg_prepared_xacts" , stdout => \ $psql_out );
217
+ is($psql_out , ' 1' , " Check that we restore prepared xacts after slave hard restart while master is down." );
215
218
216
219
# restore state
217
220
($node_master , $node_slave ) = ($node_slave , $node_master );
0 commit comments