Re: pg_rewind - enable wal_log_hints or data-checksums

From: Bowen Shi <zxwsbg12138(at)gmail(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Dylan Luong <Dylan(dot)Luong(at)unisa(dot)edu(dot)au>, "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: pg_rewind - enable wal_log_hints or data-checksums
Date: 2025-02-18 06:47:09
Message-ID: CAM_vCucirLRiB+cK3PWScfW=oCmBZz8oLYtwEufcMmHK-YzVsQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi Michael,

I first use initdb, and set wal_log_hints=off, data_checksums=off, and
full_page_writes=on. Starting pg and running for a while.

Then switch over happened, I used the following commands:
1. Old master postgresql.conf set wal_log_hints=on, then start and stop pg.
2. using pg_rewind --target-pgdata=OldMaster --source-server=NewMaster (no
error, old master's wal_log_hints has been set to on)

I wonder if this could lead to data corruption.

On Tue, Feb 18, 2025 at 2:27 PM Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
wrote:

> On Mon, Jun 5, 2017 at 9:37 AM, Dylan Luong <Dylan(dot)Luong(at)unisa(dot)edu(dot)au>
> wrote:
> > pg_rewind requires that the target server either has the wal_log_hints
> > option enabled in postgresql.conf or data checksums enabled when the
> cluster
> > was initialized with initdb.
>
> Yes, this is to make sure that you don't finish with a corrupted
> target server if a hint bit is set on a page after a checkpoint. Any
> of those options make sure that a full-page write is generated in this
> case.
>
> > What is the difference between the two options?
>
> Data checksums calculate 2 bytes of checksum data and write it to each
> page that is evicted from shared buffers. Each page read from disk has
> its checksum checked. In some workloads, like a heavy read load where
> a lot of page evictions happen, this can induce a couple of percents
> of performance lost. In my own experience, that's 1~2%.
>
> > What are the advantages and disadvantages between the two?
> > Which one is the the preferred option?
>
> If you care more about performance or if you use a file system that
> has its own block-level checksum, wal_log_hints would be preferred.
> Data checksums offer more guarantees in terms of integrity though when
> looking for corrupted data. Things get found more quickly.
> --
> Michael
>
>
> --
> Sent via pgsql-general mailing list (pgsql-general(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
>
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Robert Haas 2025-02-18 15:13:03 Re: Clarification on Role Access Rights to Table Indexes
Previous Message WU Yan 2025-02-18 01:14:23 Re: Wasteful nested loop join when there is `limit` in the query