Re: Offline enabling/disabling of data checksums
Fabien COELHO <coelho@cri.ensmp.fr>
From: Fabien COELHO <coelho@cri.ensmp.fr>
To: Michael Paquier <michael@paquier.xyz>
Cc: Michael Banck <michael.banck@credativ.de>,
Magnus Hagander <magnus@hagander.net>, Sergei Kornilov <sk@zsrv.org>,
PostgreSQL Developers <pgsql-hackers@lists.postgresql.org>
Date: 2019-03-19T12:45:40Z
Lists: pgsql-hackers
>> Ok, this might not work, because of the following, less likely, race >> condition: >> >> postmaster opens control file RW >> pg_checksums moves control file, postmater open file handle follows >> ... >> >> So ISTM that we really need some locking to have something clean. > > We are talking about complicating a method which is already fine for a > a window where the whole operation works, as it could take hours to > enable checksums, versus a couple of instructions. I am not sure that > it is worth complicating the code more. Hmmm. Possibly. The point is that anything only needs to be implemented once. The whole point of pg is to have ACID transactional properties, but it does not achieve that on the controlfile, which I find paradoxical:-) Now if there is a race condition opportunity, ISTM that it should be as short as possible. Renaming before manipulating seems safer if other commands proceeds like that as well. Probably if pg always rename *THEN* open before doing anything in all commands it could be safe, provided that the renaming is atomic, which I think is the case. That would avoid locking, at the price of a small probability of having a controlfile in a controlfile.command-that-failed-at-the-wrong-time state. Maybe it is okay. Maybe there is a need to be able to force the state back to something to recover from such unlikely event, but probably it does already exists (eg postmaster could be dead without releasing the controlfile state). -- Fabien.
Commits
-
Reorganize Notes section in documentation of pg_checksums
- a7cc52370b2b 12.0 landed
-
Add option -N/--no-sync to pg_checksums
- e0090c869008 12.0 landed
-
Add options to enable and disable checksums in pg_checksums
- ed308d783790 12.0 landed
-
Refactor more code logic to update the control file
- 8b938d36f744 12.0 landed
-
Rename pg_verify_checksums to pg_checksums
- 6dd263cfaa84 12.0 landed
-
Fix cross-version compatibility checks of pg_verify_checksums
- 501f58359b59 11.3 landed
- c9ae7f704c67 12.0 landed
-
Add routine able to update the control file to src/common/
- ce6afc6823fb 12.0 landed