@@ -168,27 +168,25 @@ sub change_hot_standby_feedback_and_wait_for_xmins
168
168
}
169
169
}
170
170
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
173
173
{
174
- my ($conflicting ) = @_ ;
174
+ my ($slot_prefix , $reason ) = @_ ;
175
175
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' ;
181
178
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 ';) );
189
182
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 " );
192
190
}
193
191
194
192
# Drop the slots, re-create them, change hot_standby_feedback,
@@ -260,13 +258,13 @@ sub check_for_invalidation
260
258
qq[ SELECT * FROM pg_create_physical_replication_slot('$primary_slotname ');]
261
259
);
262
260
263
- # Check conflicting is NULL for physical slot
261
+ # Check conflict_reason is NULL for physical slot
264
262
$res = $node_primary -> safe_psql(
265
263
' 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 ';]
267
265
);
268
266
269
- is($res , ' t' , " Physical slot reports conflicting as NULL" );
267
+ is($res , ' t' , " Physical slot reports conflict_reason as NULL" );
270
268
271
269
my $backup_name = ' b1' ;
272
270
$node_primary -> backup($backup_name );
@@ -483,8 +481,8 @@ sub check_for_invalidation
483
481
# Check invalidation in the logfile and in pg_stat_database_conflicts
484
482
check_for_invalidation(' vacuum_full_' , 1, ' with vacuum FULL on pg_class' );
485
483
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 ' );
488
486
489
487
$handle =
490
488
make_slot_active($node_standby , ' vacuum_full_' , 0, \$stdout , \$stderr );
@@ -502,16 +500,16 @@ sub check_for_invalidation
502
500
# #################################################
503
501
$node_standby -> restart;
504
502
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 ' );
507
505
508
506
# #################################################
509
507
# Verify that invalidated logical slots do not lead to retaining WAL.
510
508
# #################################################
511
509
512
510
# Get the restart_lsn from an invalidated slot
513
511
my $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 ;"
515
513
);
516
514
517
515
chomp ($restart_lsn );
@@ -565,8 +563,8 @@ sub check_for_invalidation
565
563
# Check invalidation in the logfile and in pg_stat_database_conflicts
566
564
check_for_invalidation(' row_removal_' , $logstart , ' with vacuum on pg_class' );
567
565
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 ' );
570
568
571
569
$handle =
572
570
make_slot_active($node_standby , ' row_removal_' , 0, \$stdout , \$stderr );
@@ -604,8 +602,8 @@ sub check_for_invalidation
604
602
check_for_invalidation(' shared_row_removal_' , $logstart ,
605
603
' with vacuum on pg_authid' );
606
604
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 ' );
609
607
610
608
$handle = make_slot_active($node_standby , ' shared_row_removal_' , 0, \$stdout ,
611
609
\$stderr );
@@ -657,7 +655,13 @@ sub check_for_invalidation
657
655
) or die " Timed out waiting confl_active_logicalslot to be updated" ;
658
656
659
657
# 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' );
661
665
662
666
# Turn hot_standby_feedback back on
663
667
change_hot_standby_feedback_and_wait_for_xmins(1, 0);
@@ -693,8 +697,8 @@ sub check_for_invalidation
693
697
# Check invalidation in the logfile and in pg_stat_database_conflicts
694
698
check_for_invalidation(' pruning_' , $logstart , ' with on-access pruning' );
695
699
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 ' );
698
702
699
703
$handle = make_slot_active($node_standby , ' pruning_' , 0, \$stdout , \$stderr );
700
704
@@ -737,8 +741,8 @@ sub check_for_invalidation
737
741
# Check invalidation in the logfile and in pg_stat_database_conflicts
738
742
check_for_invalidation(' wal_level_' , $logstart , ' due to wal_level' );
739
743
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 ' );
742
746
743
747
$handle =
744
748
make_slot_active($node_standby , ' wal_level_' , 0, \$stdout , \$stderr );
0 commit comments