@@ -168,27 +168,25 @@ sub change_hot_standby_feedback_and_wait_for_xmins
168168 }
169169}
170170
171- # Check conflicting status in pg_replication_slots.
172- sub check_slots_conflicting_status
171+ # Check conflict_reason in pg_replication_slots.
172+ sub check_slots_conflict_reason
173173{
174- my ($conflicting ) = @_ ;
174+ my ($slot_prefix , $reason ) = @_ ;
175175
176- if ($conflicting )
177- {
178- $res = $node_standby -> safe_psql(
179- ' postgres' , qq(
180- select bool_and(conflicting) from pg_replication_slots;) );
176+ my $active_slot = $slot_prefix . ' activeslot' ;
177+ my $inactive_slot = $slot_prefix . ' inactiveslot' ;
181178
182- is($res , ' t' , " Logical slots are reported as conflicting" );
183- }
184- else
185- {
186- $res = $node_standby -> safe_psql(
187- ' postgres' , qq(
188- select bool_or(conflicting) from pg_replication_slots;) );
179+ $res = $node_standby -> safe_psql(
180+ ' postgres' , qq(
181+ select conflict_reason from pg_replication_slots where slot_name = '$active_slot ';) );
189182
190- is($res , ' f' , " Logical slots are reported as non conflicting" );
191- }
183+ is($res , " $reason " , " $active_slot conflict_reason is $reason " );
184+
185+ $res = $node_standby -> safe_psql(
186+ ' postgres' , qq(
187+ select conflict_reason from pg_replication_slots where slot_name = '$inactive_slot ';) );
188+
189+ is($res , " $reason " , " $inactive_slot conflict_reason is $reason " );
192190}
193191
194192# Drop the slots, re-create them, change hot_standby_feedback,
@@ -260,13 +258,13 @@ sub check_for_invalidation
260258 qq[ SELECT * FROM pg_create_physical_replication_slot('$primary_slotname ');]
261259);
262260
263- # Check conflicting is NULL for physical slot
261+ # Check conflict_reason is NULL for physical slot
264262$res = $node_primary -> safe_psql(
265263 ' postgres' , qq[
266- SELECT conflicting is null FROM pg_replication_slots where slot_name = '$primary_slotname ';]
264+ SELECT conflict_reason is null FROM pg_replication_slots where slot_name = '$primary_slotname ';]
267265);
268266
269- is($res , ' t' , " Physical slot reports conflicting as NULL" );
267+ is($res , ' t' , " Physical slot reports conflict_reason as NULL" );
270268
271269my $backup_name = ' b1' ;
272270$node_primary -> backup($backup_name );
@@ -483,8 +481,8 @@ sub check_for_invalidation
483481# Check invalidation in the logfile and in pg_stat_database_conflicts
484482check_for_invalidation(' vacuum_full_' , 1, ' with vacuum FULL on pg_class' );
485483
486- # Verify slots are reported as conflicting in pg_replication_slots
487- check_slots_conflicting_status(1 );
484+ # Verify conflict_reason is 'rows_removed' in pg_replication_slots
485+ check_slots_conflict_reason( ' vacuum_full_ ' , ' rows_removed ' );
488486
489487$handle =
490488 make_slot_active($node_standby , ' vacuum_full_' , 0, \$stdout , \$stderr );
@@ -502,16 +500,16 @@ sub check_for_invalidation
502500# #################################################
503501$node_standby -> restart;
504502
505- # Verify slots are reported as conflicting in pg_replication_slots
506- check_slots_conflicting_status(1 );
503+ # Verify conflict_reason is retained across a restart.
504+ check_slots_conflict_reason( ' vacuum_full_ ' , ' rows_removed ' );
507505
508506# #################################################
509507# Verify that invalidated logical slots do not lead to retaining WAL.
510508# #################################################
511509
512510# Get the restart_lsn from an invalidated slot
513511my $restart_lsn = $node_standby -> safe_psql(' postgres' ,
514- " SELECT restart_lsn from pg_replication_slots WHERE slot_name = 'vacuum_full_activeslot' and conflicting is true ;"
512+ " SELECT restart_lsn from pg_replication_slots WHERE slot_name = 'vacuum_full_activeslot' and conflict_reason is not null ;"
515513);
516514
517515chomp ($restart_lsn );
@@ -565,8 +563,8 @@ sub check_for_invalidation
565563# Check invalidation in the logfile and in pg_stat_database_conflicts
566564check_for_invalidation(' row_removal_' , $logstart , ' with vacuum on pg_class' );
567565
568- # Verify slots are reported as conflicting in pg_replication_slots
569- check_slots_conflicting_status(1 );
566+ # Verify conflict_reason is 'rows_removed' in pg_replication_slots
567+ check_slots_conflict_reason( ' row_removal_ ' , ' rows_removed ' );
570568
571569$handle =
572570 make_slot_active($node_standby , ' row_removal_' , 0, \$stdout , \$stderr );
@@ -604,8 +602,8 @@ sub check_for_invalidation
604602check_for_invalidation(' shared_row_removal_' , $logstart ,
605603 ' with vacuum on pg_authid' );
606604
607- # Verify slots are reported as conflicting in pg_replication_slots
608- check_slots_conflicting_status(1 );
605+ # Verify conflict_reason is 'rows_removed' in pg_replication_slots
606+ check_slots_conflict_reason( ' shared_row_removal_ ' , ' rows_removed ' );
609607
610608$handle = make_slot_active($node_standby , ' shared_row_removal_' , 0, \$stdout ,
611609 \$stderr );
@@ -657,7 +655,13 @@ sub check_for_invalidation
657655) or die " Timed out waiting confl_active_logicalslot to be updated" ;
658656
659657# Verify slots are reported as non conflicting in pg_replication_slots
660- check_slots_conflicting_status(0);
658+ is( $node_standby -> safe_psql(
659+ ' postgres' ,
660+ q[ select bool_or(conflicting) from
661+ (select conflict_reason is not NULL as conflicting
662+ from pg_replication_slots WHERE slot_type = 'logical')] ),
663+ ' f' ,
664+ ' Logical slots are reported as non conflicting' );
661665
662666# Turn hot_standby_feedback back on
663667change_hot_standby_feedback_and_wait_for_xmins(1, 0);
@@ -693,8 +697,8 @@ sub check_for_invalidation
693697# Check invalidation in the logfile and in pg_stat_database_conflicts
694698check_for_invalidation(' pruning_' , $logstart , ' with on-access pruning' );
695699
696- # Verify slots are reported as conflicting in pg_replication_slots
697- check_slots_conflicting_status(1 );
700+ # Verify conflict_reason is 'rows_removed' in pg_replication_slots
701+ check_slots_conflict_reason( ' pruning_ ' , ' rows_removed ' );
698702
699703$handle = make_slot_active($node_standby , ' pruning_' , 0, \$stdout , \$stderr );
700704
@@ -737,8 +741,8 @@ sub check_for_invalidation
737741# Check invalidation in the logfile and in pg_stat_database_conflicts
738742check_for_invalidation(' wal_level_' , $logstart , ' due to wal_level' );
739743
740- # Verify slots are reported as conflicting in pg_replication_slots
741- check_slots_conflicting_status(1 );
744+ # Verify conflict_reason is 'wal_level_insufficient' in pg_replication_slots
745+ check_slots_conflict_reason( ' wal_level_ ' , ' wal_level_insufficient ' );
742746
743747$handle =
744748 make_slot_active($node_standby , ' wal_level_' , 0, \$stdout , \$stderr );
0 commit comments