Add PostgreSQL::Test::Cluster::wait_for_event()
Per a demand from the author and the reviewer of this commit, this adds to Cluster.pm a helper routine that can be used to monitor when a process reaches a wanted wait event. This can be used in combination with the module injection_points for the "wait" callback, though it is not limited to it as this monitors pg_stat_activity for a wait_event and a backend_type. Author: Bertrand Drouvot Reviewed-by: Andrey Borodin Discussion: https://postgr.es/m/ZeBB4RMPEZ06TcdY@ip-10-97-1-34.eu-west-3.compute.internal
This commit is contained in:
parent
6782709df8
commit
eca2c1ea85
@ -2742,6 +2742,29 @@ sub lsn
|
|||||||
|
|
||||||
=pod
|
=pod
|
||||||
|
|
||||||
|
=item $node->wait_for_event(wait_event_name, backend_type)
|
||||||
|
|
||||||
|
Poll pg_stat_activity until backend_type reaches wait_event_name.
|
||||||
|
|
||||||
|
=cut
|
||||||
|
|
||||||
|
sub wait_for_event
|
||||||
|
{
|
||||||
|
my ($self, $backend_type, $wait_event_name) = @_;
|
||||||
|
|
||||||
|
$self->poll_query_until(
|
||||||
|
'postgres', qq[
|
||||||
|
SELECT count(*) > 0 FROM pg_stat_activity
|
||||||
|
WHERE backend_type = '$backend_type' AND wait_event = '$wait_event_name'
|
||||||
|
])
|
||||||
|
or die
|
||||||
|
qq(timed out when waiting for $backend_type to reach wait event '$wait_event_name');
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
=pod
|
||||||
|
|
||||||
=item $node->wait_for_catchup(standby_name, mode, target_lsn)
|
=item $node->wait_for_catchup(standby_name, mode, target_lsn)
|
||||||
|
|
||||||
Wait for the replication connection with application_name standby_name until
|
Wait for the replication connection with application_name standby_name until
|
||||||
|
@ -78,13 +78,7 @@ $node_primary->wait_for_replay_catchup($node_standby);
|
|||||||
|
|
||||||
# Wait until the checkpointer is in the middle of the restart point
|
# Wait until the checkpointer is in the middle of the restart point
|
||||||
# processing.
|
# processing.
|
||||||
ok( $node_standby->poll_query_until(
|
$node_standby->wait_for_event('checkpointer', 'create-restart-point');
|
||||||
'postgres',
|
|
||||||
qq[SELECT count(*) FROM pg_stat_activity
|
|
||||||
WHERE backend_type = 'checkpointer' AND wait_event = 'create-restart-point' ;],
|
|
||||||
'1'),
|
|
||||||
'checkpointer is waiting in restart point'
|
|
||||||
) or die "Timed out while waiting for checkpointer to run restart point";
|
|
||||||
|
|
||||||
# Check the logs that the restart point has started on standby. This is
|
# Check the logs that the restart point has started on standby. This is
|
||||||
# optional, but let's be sure.
|
# optional, but let's be sure.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user