From: Michael Paquier <michael@paquier.xyz>
To: pgsql-general@lists.postgresql.org
Subject: Re: pg_checksums?
Date: Mon, 30 Oct 2023 09:56:31 +0900
Message-ID: <ZT7_P9A_OrKgP5yn@paquier.xyz> (raw)
In-Reply-To: <20231029104911.dj73ivozabdr5or4@hjp.at>
References: <22272207-E6E5-4DD5-9BD4-5F6B647E2C3B@gmail.com>
<0D18D31E-EF52-434D-875C-08BEC8DDD553@yesql.se>
<ZTwpx1sCIu-4EgRH@momjian.us>
<AB7D1C87-F9E6-4068-9AA9-8591C82CF9CC@gmail.com>
<20231029014310.7pbdfhincj2tds4l@hjp.at>
<81D43A87-7D3D-4F81-B462-641F15B5E332@gmail.com>
<20231029104911.dj73ivozabdr5or4@hjp.at>
On Sun, Oct 29, 2023 at 11:49:11AM +0100, Peter J. Holzer wrote:
> On 2023-10-29 10:11:07 +0100, Paul Förster wrote:
>> On Oct 29, 2023, at 02:43, Peter J. Holzer <hjp-pgsql@hjp.at> wrote:
>>> I don't think so. AFAIK Replication keeps the data files in sync on a
>>> bit-for-bit level and turning on checksums changes the data layout.
>>> Running a cluster where one node has checksums and the other doesn't
>>> would result in a complete mess.
>>
>> I agree with the last sentence. This is why I asked if it is safe to
>> enable checksums on a replica, switch over and then do it again on the
>> ex primary, i.e. now new replica without doing a reinit.
>
> It *might* work if there are zero writes on the primary during the
> downtime of the replica (because those writes couldn't be replicated),
> but that seems hard to ensure. Even if you could get away with making
> the primary read-only (is this even possible?) I wouldn't have much
> confidence in the result and reinit the (new) replica anyway.
Hm? Page checksums are written when a page is flushed to disk, we
don't set them for dirty buffers or full-page writes included in WAL,
so it should be OK to do something like the following:
- Stop cleanly a standby.
- Run pg_checksums on the standby to enable them.
- Restart the standby.
- Catchup with the latest changes
- Stop cleanly the primary, letting the shutdown checkpoint be
replicated to the standby.
- Promote the standby.
- Enable checksums on the previous primary.
- Start the previous primary to be a standby of the node you failed
over to.
--
Michael
Attachments:
signature.asc (application/pgp-signature, 832B) download
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: michael@paquier.xyz
Subject: Re: pg_checksums?
In-Reply-To: <ZT7_P9A_OrKgP5yn@paquier.xyz>
References: <22272207-E6E5-4DD5-9BD4-5F6B647E2C3B@gmail.com> <0D18D31E-EF52-434D-875C-08BEC8DDD553@yesql.se> <ZTwpx1sCIu-4EgRH@momjian.us> <AB7D1C87-F9E6-4068-9AA9-8591C82CF9CC@gmail.com> <20231029014310.7pbdfhincj2tds4l@hjp.at> <81D43A87-7D3D-4F81-B462-641F15B5E332@gmail.com> <20231029104911.dj73ivozabdr5or4@hjp.at> <ZT7_P9A_OrKgP5yn@paquier.xyz>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox