'ALTER SYSTEM RESET max_wal_size; SELECT pg_reload_conf()');
 $node_primary->safe_psql('postgres', "CHECKPOINT;");
 my $invalidated = 0;
-for (my $i = 0; $i < 10000; $i++)
+for (my $i = 0; $i < 10 * $PostgreSQL::Test::Utils::timeout_default; $i++)
 {
    if (find_in_log(
            $node_primary, 'invalidating obsolete replication slot "rep1"',
 
 # Wait until current checkpoint ends
 my $checkpoint_ended = 0;
-for (my $i = 0; $i < 10000; $i++)
+for (my $i = 0; $i < 10 * $PostgreSQL::Test::Utils::timeout_default; $i++)
 {
    if (find_in_log($node_primary, "checkpoint complete: ", $logstart))
    {
 $node_standby->start;
 
 my $failed = 0;
-for (my $i = 0; $i < 10000; $i++)
+for (my $i = 0; $i < 10 * $PostgreSQL::Test::Utils::timeout_default; $i++)
 {
    if (find_in_log(
            $node_standby,
        stderr => \$stderr);
    diag $stdout, $stderr;
 
-   # unlikely that the problem would resolve after 15s, so give up at point
-   if ($i++ == 150)
+   if ($i++ == 10 * $PostgreSQL::Test::Utils::timeout_default)
    {
        # An immediate shutdown may hide evidence of a locking bug. If
        # retrying didn't resolve the issue, shut down in fast mode.