Re: Offline enabling/disabling of data checksums
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: Fabien COELHO <coelho@cri.ensmp.fr>
Cc: Andres Freund <andres@anarazel.de>, 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-20T22:59:24Z
Lists: pgsql-hackers
On Wed, Mar 20, 2019 at 05:46:32PM +0100, Fabien COELHO wrote: > I think that the motivation/risks should appear before the solution. "As xyz > ..., ...", or there at least the logical link should be outlined. > > It is not clear for me whether the following sentences, which seems specific > to "pg_rewind", are linked to the previous advice, which seems rather to > refer to streaming replication? Do you have a better idea of formulation? If you have a failover which makes use of pg_rewind, or use some backup tool which does incremental copy of physical blocks like pg_rman, then you have a risk to mess up instances in a cluster which is the risk I am trying to outline here. It is actually fine to do the following actually if everything is WAL-based as checksums are only computed once a shared buffer is flushed on a single instance. Imagine for example a primary-standby with checksums disabled: - Shutdown cleanly standby, enable checksums. - Plug back standby to cluster, let it replay up to the latest point. - Shutdown cleanly primary. - Promote standby. - Enable checksums on the previous primary. - Add recovery parameters and recommend the primary back to the cluster. - All nodes have checksums enabled, without rebuilding any of them. Per what I could see on this thread, folks tend to point out that we should *not* include such recommendations in the docs, as it is too easy to do a pilot error. > > + When using a cluster with > > + tools which perform direct copies of relation file blocks (for example > > + <xref linkend="app-pgrewind"/>), enabling or disabling checksums can > > + lead to page corruptions in the shape of incorrect checksums if the > > + operation is not done consistently across all nodes. Destroying all > > + the standbys in a cluster first, enabling or disabling checksums on > > + the primary and finally recreate the cluster nodes from scratch is > > + also safe. > > + </para> > > + </refsect1> > > Should not disabling in reverse order be safe? the checksum are not checked > afterwards? I don't quite understand your comment about the ordering. If all the standbys are destroyed first, then enabling/disabling checksums happens at a single place. > After the reboot, some data files are not fully updated with their > checksums, although the controlfiles tells that they are. It should then > fail after a restart when a no-checksum page is loaded? > > What am I missing? Please note that we do that in other tools as well and we live fine with that as pg_basebackup, pg_rewind just to name two. I am not saying that it is not a problem in some cases, but I am saying that this is not a problem that this patch should solve. If we were to do something about that, it could make sense to make fsync_pgdata() smarter so as the control file is flushed last there, or define flush strategies there. -- Michael
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