Re: pgsql: psql: Add test for query canceling

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>
Cc: Daniel Gustafsson <daniel(at)yesql(dot)se>, Fabien COELHO <coelho(at)cri(dot)ensmp(dot)fr>, pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: Re: pgsql: psql: Add test for query canceling
Date: 2021-08-24 16:59:10
Message-ID: 350197.1629824350@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com> writes:
> Here is a proposal. It waits separately for the pid file to appear and
> also checks for the sleep query to be registered by the backend, so it
> doesn't have any more dependencies on things happening "fast enough".
> And it's also faster in the normal case now. Thoughts?

That looks pretty solid to me, and I can confirm that it passes
on wrasse's host. The only nit I can find to pick is that this:

+ usleep(10_000) until -s "$tempdir/psql.pid" or ($count++ > 180 * 100 and die 'pid file did not appear');

basically assumes that psql.pid will be written atomically.
It'd be marginally safer to wait till psql.pid can be seen to
contain a newline. I don't think that would be too hard to do,
if you put the slurp_file call inside the wait loop and inspect
its result.

regards, tom lane

In response to

Responses

Browse pgsql-committers by date

  From Date Subject
Next Message Daniel Gustafsson 2021-08-24 18:26:40 Re: pgsql: psql: Add test for query canceling
Previous Message Peter Eisentraut 2021-08-24 16:43:38 Re: pgsql: psql: Add test for query canceling