Re: odd buildfarm failure - "pg_ctl: control file appears to be corrupt"
Thomas Munro <thomas.munro@gmail.com>
From: Thomas Munro <thomas.munro@gmail.com>
To: "Anton A. Melnikov" <aamelnikov@inbox.ru>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, Andres Freund <andres@anarazel.de>,
pgsql-hackers@postgresql.org
Date: 2023-01-31T11:38:33Z
Lists: pgsql-hackers
Attachments
- 0001-Lock-pg_control-while-reading-or-writing.patch (text/x-patch) patch 0001
On Tue, Jan 31, 2023 at 5:09 PM Thomas Munro <thomas.munro@gmail.com> wrote: > Clearly there is an element of speculation or superstition here. I > don't know what else to do if both PostgreSQL and ext4 decided not to > add interlocking. Maybe we should rethink that. How bad would it > really be if control file access used POSIX file locking? I mean, the > writer is going to *fsync* the file, so it's not like one more wafer > thin system call is going to hurt too much. Here's an experimental patch for that alternative. I wonder if someone would want to be able to turn it off for some reason -- maybe some NFS problem? It's less back-patchable, but maybe more principled? I don't know if Windows suffers from this type of problem. Unfortunately its equivalent functionality LockFile() looks non-ideal for this purpose: if your program crashes, the documentation is very vague on when exactly it is released by the OS, but it's not immediately on process exit. That seems non-ideal for a control file you might want to access again very soon after a crash, to be able to recover. A thought in passing: if UpdateMinRecoveryPoint() performance is an issue, maybe we should figure out how to use fdatasync() instead of fsync().
Commits
-
Try to handle torn reads of pg_control in frontend.
- 63a582222c6b 17.0 landed
- 43c979086825 12.17 landed
- 67060be3df34 13.13 landed
- dc75748a918e 14.10 landed
- 5e39884d322a 15.5 landed
- 5725e4ebe7a9 16.1 landed
-
Acquire ControlFileLock in relevant SQL functions.
- f1634c968101 11.22 landed
- 637e86ecc5e4 12.17 landed
- ae9da357bd6d 13.13 landed
- a56fe5cf07fe 14.10 landed
- 606be8a35d97 15.5 landed
- 2371432cd6b9 16.1 landed
- c558e6fd92ff 17.0 landed