Re: Direct I/O
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Thomas Munro <thomas.munro@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Andrew Dunstan <andrew@dunslane.net>, Andrea Gelmini <andrea.gelmini@gmail.com>, Heikki Linnakangas <hlinnaka@iki.fi>, Noah Misch <noah@leadboat.com>, Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>, Justin Pryzby <pryzby@telsasoft.com>, pgsql-hackers@postgresql.org
Date: 2023-04-11T02:15:00Z
Lists: pgsql-hackers
Hi, On 2023-04-10 18:55:26 -0700, Andres Freund wrote: > On 2023-04-10 19:27:27 +1200, Thomas Munro wrote: > > On Mon, Apr 10, 2023 at 2:57 PM Andres Freund <andres@anarazel.de> wrote: > > > Have you tried to write a reproducer for this that doesn't involve postgres? > > > > I tried a bit. I'll try harder soon. > > > > > ... What kernel version did you repro > > > this on Thomas? > > > > Debian's 6.0.10-2 kernel (Debian 12 on a random laptop). Here's how I > > set up a test btrfs in case someone else wants a head start: > > > > truncate -s2G 2GB.img > > sudo losetup --show --find 2GB.img > > sudo mkfs -t btrfs /dev/loop0 # the device name shown by losetup > > sudo mkdir /mnt/tmp > > sudo mount /dev/loop0 /mnt/tmp > > sudo chown $(whoami) /mnt/tmp > > > > cd /mnt/tmp > > /path/to/initdb -D pgdata > > ... (see instructions further up for postgres command line + queries to run) > > I initially failed to repro the issue with these instructions. Turns out that > the problem does not happen if huge pages are in used - I'd configured huge > pages, so the default huge_pages=try succeeded. As soon as I disable > huge_pages explicitly, it reproduces. > > Another interesting bit is that if checksums are enabled, I also can't > reproduce the issue. Together with the huge_page issue, it does suggest that > this is somehow related to page faults. Which fits with the thread Andrea > referenced... The last iteration of the fix that I could find is: https://lore.kernel.org/linux-btrfs/20230328051957.1161316-1-hch@lst.de/T/#m1afdc3fe77e10a97302e7d80fed3efeaa297f0f7 And the fix has been merged into https://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux.git/log/?h=for-next I think that means it'll have to wait for 6.4 development to open (in a few weeks), and then will be merged into the stable branches from there. Greetings, Andres Freund
Commits
-
Rename hook functions for debug_io_direct to match variable name.
- 155c81463c26 16.0 landed
- 4f3514f201cf 17.0 landed
-
Rename io_direct to debug_io_direct.
- 319bae9a8da6 16.0 landed
-
Skip the 004_io_direct.pl test if a pre-flight check fails.
- 6ca8df2d6147 16.0 landed
-
Use higher wal_level for 004_io_direct.pl.
- 980e8879f54a 16.0 landed
-
Skip \password TAP test on old IPC::Run versions
- 2e57ffe12f6b 16.0 cited
-
Add io_direct setting (developer-only).
- d4e71df6d757 16.0 landed
-
Introduce PG_IO_ALIGN_SIZE and align all I/O buffers.
- faeedbcefd40 16.0 landed
-
Add palloc_aligned() to allow aligned memory allocations
- 439f61757f05 16.0 cited
-
initdb: When running CREATE DATABASE, use STRATEGY = WAL_COPY.
- ad43a413c4f7 15.0 cited