psql's 001_basic.pl test could fail on very slow machines - Mailing list pgsql-hackers

From Oleg Tselebrovskiy
Subject psql's 001_basic.pl test could fail on very slow machines
Date
Msg-id 19b12bef6bbcb2020467804ba5445349@postgrespro.ru
Whole thread Raw
List pgsql-hackers
psql's 001_basic.pl test could fail on very slow machines

Greetings, everyone!

I've gotten a very-very rare failure of psql's 001_basic.pl:

    # +++ tap check in src/bin/psql +++
    t/001_basic.pl ................. 79/?
    #   Failed test '\watch, 2 minimum rows: matches'
    #   at t/001_basic.pl line 380.
    #                   ''
    #     doesn't match '(?^l:^123$)'
    # Looks like you failed 1 test of 110.
    t/001_basic.pl ................. Dubious, test returned 1 (wstat 256, 
0x100)
    Failed 1/110 subtests

The failed query itself:

    psql_like(
        $node,
        sprintf(
            q{with x as (
            select now()-backend_start AS howlong
            from pg_stat_activity
            where pid = pg_backend_pid()
        ) select 123 from x where howlong < '2 seconds' \watch i=%g m=2}, 
0.5),
        qr/^123$/,
        '\watch, 2 minimum rows');

It seems that on very slow machines time between backend's start and
actual query execution can be more than two seconds

You can reproduce something similar with first attached patch,
manual_reproduction, using post_auth_delay

This can be reproduced on 17+ since this is when m[in_rows] was
introduced

Since this test checks that "\watch" clause "m[in_rows]" stops query
execution if amount of rows is less than the value of m,
we could simplify the test by replacing pg_stat_activity access
with plain select (see second attached patch, rewrite_test)
Attachment

pgsql-hackers by date:

Previous
From: David Geier
Date:
Subject: Re: Use correct collation in pg_trgm
Next
From: David Geier
Date:
Subject: Re: Reduce build times of pg_trgm GIN indexes