##################################################
# Recovery conflict: Invalidate conflicting slots, including in-use slots
# Scenario 1: hot_standby_feedback off and vacuum FULL
+#
+# In passing, ensure that replication slot stats are not removed when the
+# active slot is invalidated.
##################################################
# One way to produce recovery conflict is to create/drop a relation and
reactive_slots_change_hfs_and_wait_for_xmins('behaves_ok_', 'vacuum_full_',
0, 1);
+# Ensure that replication slot stats are not empty before triggering the
+# conflict.
+$node_primary->safe_psql('testdb',
+ qq[INSERT INTO decoding_test(x,y) SELECT 100,'100';]);
+
+$node_standby->poll_query_until('testdb',
+ qq[SELECT total_txns > 0 FROM pg_stat_replication_slots WHERE slot_name = 'vacuum_full_activeslot']
+) or die "replication slot stats of vacuum_full_activeslot not updated";
+
# This should trigger the conflict
wait_until_vacuum_can_remove(
'full', 'CREATE TABLE conflict_test(x integer, y text);
# Verify conflict_reason is 'rows_removed' in pg_replication_slots
check_slots_conflict_reason('vacuum_full_', 'rows_removed');
+# Ensure that replication slot stats are not removed after invalidation.
+is( $node_standby->safe_psql(
+ 'testdb',
+ qq[SELECT total_txns > 0 FROM pg_stat_replication_slots WHERE slot_name = 'vacuum_full_activeslot']
+ ),
+ 't',
+ 'replication slot stats not removed after invalidation');
+
$handle =
make_slot_active($node_standby, 'vacuum_full_', 0, \$stdout, \$stderr);