Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tkHOA-002CNV-7G for pgsql-general@arkaria.postgresql.org; Tue, 18 Feb 2025 06:47:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1tkHO8-007GV0-Hb for pgsql-general@arkaria.postgresql.org; Tue, 18 Feb 2025 06:47:24 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tkHO8-007GUr-5C for pgsql-general@lists.postgresql.org; Tue, 18 Feb 2025 06:47:24 +0000 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tkHO5-001VUk-1o for pgsql-general@postgresql.org; Tue, 18 Feb 2025 06:47:23 +0000 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-abb86beea8cso426948766b.1 for ; Mon, 17 Feb 2025 22:47:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1739861240; x=1740466040; darn=postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=e66pcrGWBCD0XFD+Ba3xyL9+hRARTCJou/9fiiU0rgs=; b=GXltWY1Ujqhc9dr57yvELIqmksxqRrFocuYjy3MkTYYuac2RI4V9psOw4eDKPNuIoj z2L78WoSaHYXKrrq/I56Fl1cIvjR8YG3Nfh2xRsK6+dPHwHXVxPfjsSUk4q+bDA6N08u 3C9ZyopKulH1+mafzRr2QSYAG6yT7/FUHLFcPsWJ7GmCHbvKdFzHX/5AMLwbEaDe4G2m 8Kj45JA0/mBSMGTtjBzM0xR+Mt5YiUvJDLUOE2f3EwCiAsohr8Yv+wGR396eXh45Y6HE WWfyAXYntx8nHKEY4V2zUSOZ4vC2yN+yPvIm+siplhEUnGemSU+ZiBkYixvgerJyMu7H pyzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739861240; x=1740466040; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=e66pcrGWBCD0XFD+Ba3xyL9+hRARTCJou/9fiiU0rgs=; b=Gc6lu5j8WBLJZvSo4NsLTD0Y1nSmLtvEIYCcG6a8DPS5KpksqrOqH/gok+ElsD97jK Iav2w0k663exjZdk66HGBKGIBrd/8df9or1tv9HL2EPqQVUaJemtQjTGRDvy8n67zlG0 Plf9+1wEByCl4bRuqo3PWXzSVc5S+TnOhSQToAkXUyTswFp8qFJA/NXMDwQrBjMfp3P5 ssrCkeWbrKiD8wdOWoMyvcrrQGmx6kKklCiqacnEy1fFoK9tJNeXZYAGx5hbo2VaJlJk CPlXLkqVQe4cHX4ujVlMqUaOVJyo/GNf17bibB5Po+7O/O3wxjDE3+iHhBhEMJ2YhdsK jT2g== X-Forwarded-Encrypted: i=1; AJvYcCXB8i2L/aQMcNXOx/M9YQZyD0yCs1r++5yHvtVbrcqfQfdU0ijPDY4KQoTUgECVRYjbwlxOCmsKBjkAYdMc@postgresql.org X-Gm-Message-State: AOJu0YxowK6cVpSTvLROMxOHlHDRWEqIrKhxwV5VwXrwOfv8wFQvOMxj WlQEHmrC+vnwOElNuZo2hbpf7Wy9vhxUquvFTNRoYpmji0enyIFmEVOnHjY8etDQnAkZ37yy/FZ ecC26UjfV0RQ07PoHh/U2+RXW458= X-Gm-Gg: ASbGncvxBud/MPO/8Dwth8Eal0P1eaEpPs8TMT1hkPmQgy1CPhhZlYutMlPLz6Orr7W v5SFBmCHWNmIBZ23OP7cqUVrcj7ERj5MkXnlSOXfNrhk1hAAydMtkvlppsFXTjY1tu2cuXaDY X-Google-Smtp-Source: AGHT+IGiQuTyEGVVDQNhaflbXFTMPaeYDsATawErigq1aphDhnrQcmMw33WN25rnLMEW8gNHQzR2kjezj0Z9JJLFSnM= X-Received: by 2002:a17:907:7209:b0:a9e:b2da:b4a3 with SMTP id a640c23a62f3a-abb710dcd81mr1221684666b.42.1739861240087; Mon, 17 Feb 2025 22:47:20 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Bowen Shi Date: Tue, 18 Feb 2025 14:47:09 +0800 X-Gm-Features: AWEUYZlSFFbcMnUZ_o4-I528TlzycWOkkUA1ak6oVocZUK_F1vOtMad94PnuSfA Message-ID: Subject: Re: pg_rewind - enable wal_log_hints or data-checksums To: Michael Paquier Cc: Dylan Luong , "pgsql-general@postgresql.org" Content-Type: multipart/alternative; boundary="0000000000002c8f32062e650322" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --0000000000002c8f32062e650322 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Michael, I first use initdb, and set wal_log_hints=3Doff, data_checksums=3Doff, and full_page_writes=3Don. 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=3Don, then start and stop p= g. 2. using pg_rewind --target-pgdata=3DOldMaster --source-server=3DNewMaster= (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=E2=80=AFPM Michael Paquier wrote: > On Mon, Jun 5, 2017 at 9:37 AM, Dylan Luong > 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@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-general > > > --0000000000002c8f32062e650322 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Michael,

I first use initdb, and set wal_log_hin= ts=3Doff, data_checksums=3Doff, and full_page_writes=3Don. 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=3Don, then st= art and stop pg.=C2=A0
2. using =C2=A0pg_rewind --target-pgdata=3DOldMas= ter --source-server=3DNewMaster (no error, old master's wal_log_hints h= as been set to on)

I wonder if this could lead to da= ta corruption.



On Tue, Fe= b 18, 2025 at 2:27=E2=80=AFPM Michael Paquier <michael.paquier@gmail.com> wrote:
On Mon, Jun 5, 2017 at 9:37 AM= , Dylan Luong <Dylan.Luong@unisa.edu.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 c= luster
> 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@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general=


--0000000000002c8f32062e650322--