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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Cc: "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 15:03:03
Message-ID: 2423966.1728486183@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Heikki Linnakangas <hlinnaka(at)iki(dot)fi> writes:
> This issue is present on newer versions still.

Here's the problem:

long sleep_ms = (long) (sleep * 1000);

If "sleep" is less than 0.0005, sleep_ms rounds to zero, which
results in the subsequent setitimer disarming rather than
arming the interrupt.

There is an uncommented

if (sleep == 0)
continue;

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.

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexander Kuznetsov 2024-10-09 15:23:40 Re: [PATCH] Check for TupleTableSlot nullness before dereferencing
Previous Message Aleksander Alekseev 2024-10-09 14:39:22 [PATCH] Refactor bytea_sortsupport()