Re: Safeguards against incorrect fd flags for fsync()

Michael Banck <mbanck@gmx.net>

From: Michael Banck <mbanck@gmx.net>
To: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Michael Paquier <michael@paquier.xyz>, Postgres hackers <pgsql-hackers@lists.postgresql.org>
Date: 2025-06-11T19:24:24Z
Lists: pgsql-hackers

Attachments

On Tue, Jun 10, 2025 at 09:09:35PM -0400, Tom Lane wrote:
> Still, I'd like to be closer to having a working Hurd buildfarm member
> before we take a portability risk that would only benefit Hurd.

I've spent some more time on this, here's the status beyond make check:

1. The pg_stat_statements entry_timestamp test fails, the
regression.diffs is attached. I ran some of test SQL manually, and it
seems the current low timer resolution leads to most/all queries
executed in it to have a plan/exec time of exactly 0, thus tripping up
the test.

2. The isolation tests pass except for the The stats isolation test,
again timer resolution issues, the regression.diffs is attached as well.

From a quick look, I don't think there's a reasonable way to change
those tests so that they would pass on 10ms timers, timing is pretty
badly broken. To illustrate:

|regression=# \timing on
|Timing is on.
|regression=# SELECT 1;
| ?column? 
|----------
|        1
|(1 row)
|
|Time: 10.000 ms
|regression=# SELECT pg_sleep(0.011);
| pg_sleep 
|----------
| 
|(1 row)
|
|Time: 20.000 ms
|regression=# SELECT pg_sleep(0.021);
| pg_sleep 
|----------
| 
|(1 row)
|
|Time: 30.000 ms
|regression=# \timing off
|Timing is off.
|regression=# EXPLAIN (ANALYZE) SELECT 1;
|                                      QUERY PLAN                                       
|---------------------------------------------------------------------------------------
| Result  (cost=0.00..0.01 rows=1 width=4) (actual time=0.000..0.000
|rows=1.00 loops=1)
| Planning Time: 0.000 ms
| Execution Time: 0.000 ms
|(3 rows)

However otherwise, the buildfarm client completes for master if I
disable those (pg_stat_statments/entry_timestamp and
isolation_tests/stats) tests for now.

So it seems the low-resolution timer is the only functional issue right
now. I upgraded my VM to current Debian unstable, but unfortunately that
did not increase the timer resolution is hoped, maybe some more pieces
in glibc are missing, I checked in on that[1]. In any case, they are
actively working on this.

However, there is another caveat:

Running "make check" manually only sometimes hangs the VM (without any
output anywhere), while running it via the buildfarm client reliably
makes it hang each time, so I added --tests=test_setup as a work-around
to test the other stages. I have not found a reason for this yet, I will
try to get a serial console working for the VM next, maybe that will
show some helpful info.

Here's a transcript of a builfarm client run using a patched source
tree:

|hurd@debian:~/build-farm-19.1$ uname -a
|GNU debian 0.9 GNU-Mach 1.8+git20230526-486/Hurd-0.9 i686-AT386 GNU
|hurd@debian:~/build-farm-19.1$ LANG=en_US.UTF-8 LC_ALL=en_US.UTF-8 ./run_build.pl --test --config build-farm.conf --from-source=../postgres/ --tests=test_setup HEAD
|Wed Jun 11 12:41:06 2025: buildfarm run for hurd:HEAD starting
|hurd:HEAD          [12:41:07] running configure ...
|hurd:HEAD          [12:41:09] running build ...
|hurd:HEAD          [12:48:49] running basic regression tests ...
|hurd:HEAD          [12:49:08] running make contrib ...
|hurd:HEAD          [12:50:00] running make testmodules ...
|hurd:HEAD          [12:50:11] running install ...
|hurd:HEAD          [12:50:27] running make contrib install ...
|hurd:HEAD          [12:50:31] running testmodules install ...
|hurd:HEAD          [12:50:34] running make check miscellaneous modules ...
|hurd:HEAD          [12:51:46] setting up db cluster (C)...
|hurd:HEAD          [12:51:49] starting db (C)...
|hurd:HEAD          [12:51:49] running installcheck (C)...
|hurd:HEAD          [12:51:50] restarting db (C)...
|hurd:HEAD          [12:51:53] running make isolation check ...
|hurd:HEAD          [12:53:50] restarting db (C)...
|hurd:HEAD          [12:53:53] running make PL installcheck (C)...
|hurd:HEAD          [12:54:01] restarting db (C)...
|hurd:HEAD          [12:54:03] running make contrib installcheck (C)...
|hurd:HEAD          [12:55:57] restarting db (C)...
|hurd:HEAD          [12:55:59] running make test-modules installcheck (C)...
|hurd:HEAD          [12:56:41] stopping db (C)...
|hurd:HEAD          [12:56:55] running make ecpg check ...
|hurd:HEAD          [12:57:23] OK
|Branch: HEAD
|All stages succeeded


Michael

[1] https://lists.gnu.org/archive/html/bug-hurd/2025-06/msg00003.html

Commits

  1. Make safeguard against incorrect flags for fsync more portable.

  2. Add safeguards for pg_fsync() called with incorrectly-opened fds