RE: [Patch] Optimize dropping of relation buffers using dlist
tsunakawa.takay@fujitsu.com <tsunakawa.takay@fujitsu.com>
From: "tsunakawa.takay@fujitsu.com" <tsunakawa.takay@fujitsu.com>
To: 'Thomas Munro' <thomas.munro@gmail.com>
Cc: Kyotaro Horiguchi <horikyota.ntt@gmail.com>, "k.jamison@fujitsu.com" <k.jamison@fujitsu.com>, Amit Kapila <amit.kapila16@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, Andres Freund <andres@anarazel.de>, Robert Haas <robertmhaas@gmail.com>, Tomas Vondra <tomas.vondra@2ndquadrant.com>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2020-10-23T00:56:35Z
Lists: pgsql-hackers
From: Thomas Munro <thomas.munro@gmail.com> > > I'm probably being silly, but can't we avoid the problem by using fstat() > instead of lseek(SEEK_END)? Would they return the same value from the > i-node? > > Amazingly, st_size can disagree with SEEK_END when using the Linux NFS > client, but its behaviour is worse. Here's a sequence from a Linux > NFS client talking to a Linux NFS server with no free space. This > time, I also replaced the fsync() with sleep(60), just to make it > clear that SEEK_END offset can move at any time due to asynchronous > activity in kernel threads: Thank you for experimenting. That's surely amazing. So, it makes sense for commercial DBMSs and MySQL to preallocate data files... (But IIRC, MySQL has provided an option to allocate a file per table like Postgres relatively recently.) FWIW, it seems safe to use the nodelalloc mount option with ext4 to disable delayed allocation, while xfs doesn't have such an option. > > Or, can't we just try to do BufTableLookup() one block after what > smgrnblocks() returns? > > Unfortunately the problem isn't limited to one block. You're right. The data file can be extended by multiple blocks between disk writes. Regards Takayuki Tsunakawa
Commits
-
Fix size overflow in calculation introduced by commits d6ad34f3 and bea449c6.
- 519e4c9ee21a 14.0 landed
-
Optimize DropRelFileNodesAllBuffers() for recovery.
- bea449c635c0 14.0 landed
-
Optimize DropRelFileNodeBuffers() for recovery.
- d6ad34f3410f 14.0 landed
-
Cache smgrnblocks() results in recovery.
- c5315f4f4484 14.0 cited
-
Add a check to prevent overwriting valid data if smgrnblocks() gives a
- ffae5cc5a602 8.2.0 cited