Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sGjzc-00Gc2C-5k for pgsql-general@arkaria.postgresql.org; Mon, 10 Jun 2024 18:43:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1sGjza-00Eswg-MO for pgsql-general@arkaria.postgresql.org; Mon, 10 Jun 2024 18:43:43 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1sGjza-00EswW-BH for pgsql-general@lists.postgresql.org; Mon, 10 Jun 2024 18:43:43 +0000 Received: from mail-oa1-x33.google.com ([2001:4860:4864:20::33]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sGjzY-000fkj-Jk for pgsql-general@postgresql.org; Mon, 10 Jun 2024 18:43:41 +0000 Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-2506fc3a6cfso2336664fac.2 for ; Mon, 10 Jun 2024 11:43:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718045019; x=1718649819; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=ExnKSpmVFtgkVCtUdCgup0Zf2YCERd0st2mYzq2MuSg=; b=UsKYrNmLBkxA6M54/KaFfjMRhiuMXf4PGa0A6kB2U0jzms72wRbj3ou912xbdB0Bv2 4b5Jg6s5YqUXBeSY1njHAt65Ex07TX4McHqMVBgzAD/K+Of3pgMpCXjXDHkRM/iSkKH1 qEXtvnuqXiMo4cw/zLJdIwHwS2lLF9OdXUtvVneRoHzUY+vgAboxsuiAZOkPzfdnUstG Vq8K6NMWx+qCib5jDjUSKxWEwbZ4pGOSznRAuNYSYdEseiom/nuTkyisgkG4Ib0zhngR ZJefblsNZnUVfV8/T1vZhRxJyg/cul4m5P6Yz5+gkCT6/tdTf7jebnrlSQIlGQe/sn+S r35A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718045019; x=1718649819; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=ExnKSpmVFtgkVCtUdCgup0Zf2YCERd0st2mYzq2MuSg=; b=piXXvDx89RXeoLCOaU69vdayyJjamUcJpLW4HU+rowzPMKTpCrj+fwWQi6OcWgbC8a 6DavE2LWdU/X3Mielyn7Fmx5vAb2BBQVwlGYvzLZHQu8MkcawzmF6J1t/suIGLbshjEL bz275PMHFAjaVHsFGEUcGa/CD/iZ9ylXXXdI2GPvya7DPbstolIhup35Z6NNGtaRRuzA /6ofdjteQ+y4P+/TmCKeaxn3gIuN2Oe5aeQUSlARVd9BsL+cj6V7ufZFiePI/3VF5/jy Pmw+i2fdfsv8WBORNWqZs8+1v+v/b1tfZKbqm2cw5z1+UcX+cTj4zY2Z5NqOkm0WCrZc 2aag== X-Gm-Message-State: AOJu0Yw4pxN/FIAJ6JoXtqsxmoBNCux+O/qt6f8RL7KCKznwQG56jF9N //pWq5N722ggXpUbpnurkJlnHPNFIELbrxRDAFEQJuCD4ABYXZf+uB1aFxZOJQAh+AP8wNeZxwx I18QZqC7wm2LJ2N+QIgP4b+NnuMk6bA== X-Google-Smtp-Source: AGHT+IEdr3Y9O6xjfpvrkUE23kP8nYED/UfrpEoVpqHhj4Nvqqr87ovM4WZ0uZCAFlPaqo+fiXP2mhQ6xVDeb3FpeuQ= X-Received: by 2002:a05:6870:89a0:b0:254:7d41:bfb8 with SMTP id 586e51a60fabf-2547d4264dbmr9612307fac.27.1718045019056; Mon, 10 Jun 2024 11:43:39 -0700 (PDT) MIME-Version: 1.0 References: <740207.1718036299@sss.pgh.pa.us> In-Reply-To: <740207.1718036299@sss.pgh.pa.us> From: Dominique Devienne Date: Mon, 10 Jun 2024 20:43:28 +0200 Message-ID: Subject: Re: libpq v17 PQsocketPoll timeout is not granular enough To: Tom Lane Cc: pgsql-general@postgresql.org Content-Type: multipart/alternative; boundary="00000000000011b45f061a8d87b7" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000011b45f061a8d87b7 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Bummer=E2=80=A6 I didn=E2=80=99t presume to suggest an api before, but simp= ly adding an extra int with the milliseconds offset from the time_t is simple, and trivial to plug into the implementation I saw. Callers who don=E2=80=99t ca= re can simply pass zero. while I could pass a computed time_t and ms offset using . No need for fancy types imho. Aren=E2=80=99t betas precisely for = the purpose of exposing apis to those like myself to vet them? This is also beta1, I,e, the first one. My =E2=82=AC0.02 On Mon, Jun 10, 2024 at 6:18=E2=80=AFPM Tom Lane wrote: > Dominique Devienne writes: > > PQsocketPoll() being based on time_t, it has only second resolution, > AFAIK. > > Despite the [underlying implementation in fe-misc.c][2] supporting at > > least milliseconds. > > ... > > But I think it would a pity if that unreleased API couldn't be made to > > accomodate sub-second timeouts and more use-cases, like above. > > Especially given that libpq v17 isn't out yet. I may come late to the > > game, but hopefully it is not too late. > > This is an interesting suggestion, but I think yes it's too late. > We're already past beta1 and this'd require some fairly fundamental > rethinking, since there's no easy substitute for type time_t that has > millisecond resolution. (The callers do want to specify an end time > not a timeout interval, since some of them loop around PQsocketPoll > and don't want the end time to slip.) > > I guess conceivably we could use gettimeofday() and struct timeval > instead of time() and time_t, but it'd touch a lot of places in > libpq and it'd make some of the calculations a lot more complex. > > Maybe a better idea would be to convert to using our > src/include/portability/instr_time.h abstraction? But that > would be problematic for outside callers. > > In any case this doesn't seem like a sane thing to be redesigning > post-beta. A few months ago maybe we'd have done it, but ... > > regards, tom lane > --00000000000011b45f061a8d87b7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Bummer=E2=80=A6 I didn=E2=80=99t presume to suggest = an api before, but simply adding an extra int with the milliseconds offset = from the time_t is simple, and trivial to plug into the implementation I sa= w. Callers who don=E2=80=99t care can simply pass zero. while I could pass = a computed time_t and ms offset using <chrono>. No need for fancy typ= es imho. Aren=E2=80=99t betas precisely for the purpose of exposing apis to= those like myself to vet them? This is also beta1, I,e, the first one. My = =E2=82=AC0.02

On Mon, Jun 10, 2024 at 6:18=E2=80=AFPM Tom Lane &l= t;tgl@sss.pgh.pa.us> wrote:
=
Dominique Devienne <ddevienne@gmail.com> write= s:
> PQsocketPoll() being based on time_t, it has only second resolution, A= FAIK.
> Despite the [underlying implementation in fe-misc.c][2] supporting at<= br> > least milliseconds.
> ...
> But I think it would a pity if that unreleased API couldn't be mad= e to
> accomodate sub-second timeouts and more use-cases, like above.
> Especially given that libpq v17 isn't out yet. I may come late to = the
> game, but hopefully it is not too late.

This is an interesting suggestion, but I think yes it's too late.
We're already past beta1 and this'd require some fairly fundamental=
rethinking, since there's no easy substitute for type time_t that has millisecond resolution.=C2=A0 (The callers do want to specify an end time not a timeout interval, since some of them loop around PQsocketPoll
and don't want the end time to slip.)

I guess conceivably we could use gettimeofday() and struct timeval
instead of time() and time_t, but it'd touch a lot of places in
libpq and it'd make some of the calculations a lot more complex.

Maybe a better idea would be to convert to using our
src/include/portability/instr_time.h abstraction?=C2=A0 But that
would be problematic for outside callers.

In any case this doesn't seem like a sane thing to be redesigning
post-beta.=C2=A0 A few months ago maybe we'd have done it, but ...

=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 regards, tom lane
--00000000000011b45f061a8d87b7--