@@ -146,35 +146,32 @@ sub test_target_session_attrs
146
146
" wal_receiver_status_interval = 1" );
147
147
$node_standby_2 -> restart;
148
148
149
- # Wait for given condition on slot's pg_replication_slots row --- useful for
150
- # ensuring we've reached a quiescent condition for reading slot xmins
151
- sub wait_slot_xmins
149
+ # Fetch xmin columns from slot's pg_replication_slots row, after waiting for
150
+ # given boolean condition to be true to ensure we've reached a quiescent state
151
+ sub get_slot_xmins
152
152
{
153
- my ($node , $slot_name , $check_expr ) = @_ ;
153
+ my ($node , $slotname , $check_expr ) = @_ ;
154
154
155
155
$node -> poll_query_until(' postgres' , qq[
156
156
SELECT $check_expr
157
157
FROM pg_catalog.pg_replication_slots
158
- WHERE slot_name = '$slot_name ';
158
+ WHERE slot_name = '$slotname ';
159
159
] )
160
160
or die " Timed out waiting for slot xmins to advance" ;
161
- }
162
161
163
- # Fetch xmin columns from slot's pg_replication_slots row
164
- sub get_slot_xmins
165
- {
166
- my ($node , $slotname ) = @_ ;
167
162
my $slotinfo = $node -> slot($slotname );
168
163
return ($slotinfo -> {' xmin' }, $slotinfo -> {' catalog_xmin' });
169
164
}
170
165
171
166
# There's no hot standby feedback and there are no logical slots on either peer
172
167
# so xmin and catalog_xmin should be null on both slots.
173
- my ($xmin , $catalog_xmin ) = get_slot_xmins($node_master , $slotname_1 );
168
+ my ($xmin , $catalog_xmin ) = get_slot_xmins($node_master , $slotname_1 ,
169
+ " xmin IS NULL AND catalog_xmin IS NULL" );
174
170
is($xmin , ' ' , ' xmin of non-cascaded slot null with no hs_feedback' );
175
171
is($catalog_xmin , ' ' , ' catalog xmin of non-cascaded slot null with no hs_feedback' );
176
172
177
- ($xmin , $catalog_xmin ) = get_slot_xmins($node_standby_1 , $slotname_2 );
173
+ ($xmin , $catalog_xmin ) = get_slot_xmins($node_standby_1 , $slotname_2 ,
174
+ " xmin IS NULL AND catalog_xmin IS NULL" );
178
175
is($xmin , ' ' , ' xmin of cascaded slot null with no hs_feedback' );
179
176
is($catalog_xmin , ' ' , ' catalog xmin of cascaded slot null with no hs_feedback' );
180
177
@@ -212,18 +209,14 @@ sub replay_check
212
209
$node_standby_2 -> reload;
213
210
replay_check();
214
211
215
- wait_slot_xmins($node_master , $slotname_1 ,
216
- " xmin IS NOT NULL AND catalog_xmin IS NULL" );
217
-
218
- ($xmin , $catalog_xmin ) = get_slot_xmins($node_master , $slotname_1 );
212
+ ($xmin , $catalog_xmin ) = get_slot_xmins($node_master , $slotname_1 ,
213
+ " xmin IS NOT NULL AND catalog_xmin IS NULL" );
219
214
isnt($xmin , ' ' , ' xmin of non-cascaded slot non-null with hs feedback' );
220
215
is($catalog_xmin , ' ' ,
221
216
' catalog xmin of non-cascaded slot still null with hs_feedback' );
222
217
223
- wait_slot_xmins($node_standby_1 , $slotname_2 ,
224
- " xmin IS NOT NULL AND catalog_xmin IS NULL" );
225
-
226
- my ($xmin1 , $catalog_xmin1 ) = get_slot_xmins($node_standby_1 , $slotname_2 );
218
+ my ($xmin1 , $catalog_xmin1 ) = get_slot_xmins($node_standby_1 , $slotname_2 ,
219
+ " xmin IS NOT NULL AND catalog_xmin IS NULL" );
227
220
isnt($xmin1 , ' ' , ' xmin of cascaded slot non-null with hs feedback' );
228
221
is($catalog_xmin1 , ' ' ,
229
222
' catalog xmin of cascaded slot still null with hs_feedback' );
@@ -246,17 +239,15 @@ sub replay_check
246
239
$node_master -> safe_psql(' postgres' , ' VACUUM;' );
247
240
$node_master -> safe_psql(' postgres' , ' CHECKPOINT;' );
248
241
249
- wait_slot_xmins($node_master , $slotname_1 , " xmin <> '$xmin '" );
250
-
251
- my ($xmin2 , $catalog_xmin2 ) = get_slot_xmins($node_master , $slotname_1 );
242
+ my ($xmin2 , $catalog_xmin2 ) = get_slot_xmins($node_master , $slotname_1 ,
243
+ " xmin <> '$xmin '" );
252
244
note " master slot's new xmin $xmin2 , old xmin $xmin " ;
253
245
isnt($xmin2 , $xmin , ' xmin of non-cascaded slot with hs feedback has changed' );
254
246
is($catalog_xmin2 , ' ' ,
255
247
' catalog xmin of non-cascaded slot still null with hs_feedback unchanged' );
256
248
257
- wait_slot_xmins($node_standby_1 , $slotname_2 , " xmin <> '$xmin1 '" );
258
-
259
- ($xmin2 , $catalog_xmin2 ) = get_slot_xmins($node_standby_1 , $slotname_2 );
249
+ ($xmin2 , $catalog_xmin2 ) = get_slot_xmins($node_standby_1 , $slotname_2 ,
250
+ " xmin <> '$xmin1 '" );
260
251
note " standby_1 slot's new xmin $xmin2 , old xmin $xmin1 " ;
261
252
isnt($xmin2 , $xmin1 , ' xmin of cascaded slot with hs feedback has changed' );
262
253
is($catalog_xmin2 , ' ' ,
@@ -273,18 +264,14 @@ sub replay_check
273
264
$node_standby_2 -> reload;
274
265
replay_check();
275
266
276
- wait_slot_xmins($node_master , $slotname_1 ,
277
- " xmin IS NULL AND catalog_xmin IS NULL" );
278
-
279
- ($xmin , $catalog_xmin ) = get_slot_xmins($node_master , $slotname_1 );
267
+ ($xmin , $catalog_xmin ) = get_slot_xmins($node_master , $slotname_1 ,
268
+ " xmin IS NULL AND catalog_xmin IS NULL" );
280
269
is($xmin , ' ' , ' xmin of non-cascaded slot null with hs feedback reset' );
281
270
is($catalog_xmin , ' ' ,
282
271
' catalog xmin of non-cascaded slot still null with hs_feedback reset' );
283
272
284
- wait_slot_xmins($node_standby_1 , $slotname_2 ,
285
- " xmin IS NULL AND catalog_xmin IS NULL" );
286
-
287
- ($xmin , $catalog_xmin ) = get_slot_xmins($node_standby_1 , $slotname_2 );
273
+ ($xmin , $catalog_xmin ) = get_slot_xmins($node_standby_1 , $slotname_2 ,
274
+ " xmin IS NULL AND catalog_xmin IS NULL" );
288
275
is($xmin , ' ' , ' xmin of cascaded slot null with hs feedback reset' );
289
276
is($catalog_xmin , ' ' ,
290
277
' catalog xmin of cascaded slot still null with hs_feedback reset' );
@@ -301,16 +288,14 @@ sub replay_check
301
288
' ALTER SYSTEM SET hot_standby_feedback = off;' );
302
289
$node_standby_2 -> stop;
303
290
304
- wait_slot_xmins($node_standby_1 , $slotname_2 , " xmin IS NOT NULL" );
305
-
306
- ($xmin , $catalog_xmin ) = get_slot_xmins($node_standby_1 , $slotname_2 );
291
+ ($xmin , $catalog_xmin ) = get_slot_xmins($node_standby_1 , $slotname_2 ,
292
+ " xmin IS NOT NULL" );
307
293
isnt($xmin , ' ' , ' xmin of cascaded slot non-null with postgres shut down' );
308
294
309
295
# Xmin from a previous run should be cleared on startup.
310
296
$node_standby_2 -> start;
311
297
312
- wait_slot_xmins($node_standby_1 , $slotname_2 , " xmin IS NULL" );
313
-
314
- ($xmin , $catalog_xmin ) = get_slot_xmins($node_standby_1 , $slotname_2 );
298
+ ($xmin , $catalog_xmin ) = get_slot_xmins($node_standby_1 , $slotname_2 ,
299
+ " xmin IS NULL" );
315
300
is($xmin , ' ' ,
316
301
' xmin of cascaded slot reset after startup with hs feedback reset' );
0 commit comments