Re: Improve the granularity of PQsocketPoll's timeout parameter?

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, Tristan Partin <tristan(at)partin(dot)io>, Dominique Devienne <ddevienne(at)gmail(dot)com>
Subject: Re: Improve the granularity of PQsocketPoll's timeout parameter?
Date: 2024-06-11 17:02:55
Message-ID: CA+Tgmob3qSOtaEHKsbcyhtuuF6vKN9YNZ_w6Zy__+c4E2OEaMg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Jun 10, 2024 at 5:39 PM Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> In [1] Dominique Devienne complained that PQsocketPoll would be
> far more useful to him if it had better-than-one-second timeout
> resolution. I initially pushed back on that on the grounds that
> post-beta1 is a bit late to be redefining public APIs. Which it is,
> but if we don't fix it now then we'll be stuck supporting that API
> indefinitely. And it's not like one-second resolution is great
> for our internal usage either --- for example, I see that psql
> is now doing
>
> end_time = time(NULL) + 1;
> rc = PQsocketPoll(sock, forRead, !forRead, end_time);

I agree this is not great. I guess I didn't think about it very hard
because, after all, we were just exposing an API that we'd already
been using internally. But I think it's reasonable to adjust the API
to allow for better resolution, as you propose. A second is a very
long amount of time, and it's entirely reasonable for someone to want
better granularity.

--
Robert Haas
EDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2024-06-11 17:13:48 Re: Track the amount of time waiting due to cost_delay
Previous Message Nathan Bossart 2024-06-11 16:40:36 Re: Track the amount of time waiting due to cost_delay