Re: Avoiding roundoff error in pg_sleep()
Robert Haas <robertmhaas@gmail.com>
From: Robert Haas <robertmhaas@gmail.com>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@lists.postgresql.org
Date: 2025-09-25T19:41:25Z
Lists: pgsql-hackers
On Thu, Sep 25, 2025 at 2:42 PM Tom Lane <tgl@sss.pgh.pa.us> wrote: > I chanced to notice that if you ask pg_sleep for 1ms delay, > what you actually get is 2ms, for example Oh, wow. I tested and I get the same behavior. > Anyway, I propose trying to get rid of this misbehavior by avoiding > floating point in the delay computation, as attached. Score one for my blind yet fiery hatred of floating-point arithmetic. The patch looks good except that (places tongue firmly in cheek) it will cause problems for users who want to sleep for more than 150,000 years. -- Robert Haas EDB: http://www.enterprisedb.com
Commits
-
Try to avoid floating-point roundoff error in pg_sleep().
- 02c4bc88302a 19 (unreleased) landed