# Wait for slot to first become idle and then get invalidated
sub wait_for_slot_invalidation
{
my ($node, $slot_name, $offset) = @_;
my $node_name = $node->name;
# The slot's invalidation should be logged
$node->wait_for_log(
qr/invalidating obsolete replication slot \"$slot_name\"/, $offset);
# Check that the invalidation reason is 'idle_timeout'
$node->poll_query_until( 'postgres', qq[
SELECT COUNT(slot_name) = 1 FROM pg_replication_slots
WHERE slot_name = '$slot_name' AND
invalidation_reason = 'idle_timeout';
])
or die "Timed out while waiting for invalidation reason of slot $slot_name to be set on node $node_name";
}
# ======================================================================== # Testcase start # # Test invalidation of physical replication slot and logical replication slot # due to idle timeout.
# Initialize the node
my $node = PostgreSQL::Test::Cluster->new('node');
$node->init(allows_streaming => 'logical');
# Check if the 'injection_points' extension is available, as it may be # possible that this script is run with installcheck, where the module # would not be installed by default. if (!$node->check_extension('injection_points'))
{
plan skip_all => 'Extension injection_points not installed';
}
# Register an injection point on the node to forcibly cause a slot # invalidation due to idle_timeout
$node->safe_psql('postgres', 'CREATE EXTENSION injection_points;');
# Slot invalidation occurs during a checkpoint, so perform a checkpoint to # invalidate the slots.
$node->safe_psql('postgres', "CHECKPOINT");
# Wait for slots to become inactive. Since nobody has acquired the slot yet, # it can only be due to the idle timeout mechanism.
wait_for_slot_invalidation($node, 'physical_slot', $log_offset);
wait_for_slot_invalidation($node, 'logical_slot', $log_offset);
# Check that the invalidated slot cannot be acquired
my ($result, $stdout, $stderr);
($result, $stdout, $stderr) = $node->psql( 'postgres', qq[
SELECT pg_replication_slot_advance('logical_slot', '0/1');
]);
ok( $stderr =~ /can no longer access replication slot "logical_slot"/, "detected error upon trying to acquire invalidated slot on node")
or die "could not detect error upon trying to acquire invalidated slot \"logical_slot\" on node";
# Testcase end # =============================================================================
done_testing();
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.12 Sekunden
(vorverarbeitet am 2026-08-10)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.