Re: \watch 0 or \watch 0.00001 doesn't do what I want

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>, Daniel Gustafsson <daniel(at)yesql(dot)se>
Subject: Re: \watch 0 or \watch 0.00001 doesn't do what I want
Date: 2024-10-09 23:49:44
Message-ID: ZwcWmIyf6rRLg0bT@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Oct 09, 2024 at 11:03:03AM -0400, Tom Lane wrote:
> in the loop, which I bet some cowboy added to fix the zero-wait
> problem you complained of. But it's doing the wrong thing because
> it checks sleep not sleep_ms.
>
> We should change this to test sleep_ms, and we should probably
> fix the code that says what the wait interval is to print
> sleep_ms/1000.0 not sleep. And some more comments would be good.

Cowboy of 6f9ee74d45aa reporting for duty. This was not backpatched
as of the reason written in the commit log. If folks would rather get
the zero behavior backported, I'm OK with a more aggressive backpatch
if that's the consensus. A cherry-pick of 6f9ee74d45aa down to v12 is
clean enough, with a small conflict related to pagerpipe so it looks
pretty much fine.

Also, long is 4 bytes on Windows. Should we just use uint64 for
sleep_ms? I am not sure that it is worth changing as it still gives
plenty of maximum interval time even with sleep_ms in milliseconds.

Anyway, I agree that this could be better for values with lower
digits, even if \watch would output 0s when using an internal lower
than 10^-3. How about something like the simple patch attached?
--
Michael

Attachment Content-Type Size
psql-watch.patch text/x-diff 1.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2024-10-09 23:51:40 Re: Use MAX_PARALLEL_WORKER_LIMIT consistently in guc_tables.c
Previous Message Tristan Partin 2024-10-09 23:30:13 Re: Official devcontainer config