回复: Why is XLOG_FPI_FOR_HINT always need backups?

From: zwj <757634191(at)qq(dot)com>
To: Japin Li <japinli(at)hotmail(dot)com>
Cc: pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: 回复: Why is XLOG_FPI_FOR_HINT always need backups?
Date: 2021-07-06 12:42:23
Message-ID: tencent_110D6660E3CFF3D88A177FCC0956BD98E306@qq.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thank you for reply.
You are right and the PostgreSQL server writes the entire content of each disk page to WAL during the first modification of that page after a
checkpoint while data checksum is on.

But I wonder whether it is necessary or not while my file system can protect the blocks of database to be torn. And I read a comment in function&nbsp;MarkBufferDirtyHint:
```
/*
&nbsp;* If we need to protect hint bit updates from torn writes, WAL-log a
&nbsp;* full page image of the page. This full page image is only necessary
&nbsp;* if the hint bit update is the first change to the page since the
&nbsp;* last checkpoint.
&nbsp;*
&nbsp;* We don't check full_page_writes here because that logic is included
&nbsp;* when we call XLogInsert() since the value changes dynamically.
&nbsp;*/

```
However, the code tell me it has nothing to do with full_page_writes. I can't figure it out.&nbsp;

--
Zhang Wenjie

------------------ 原始邮件 ------------------
发件人: "Japin Li" <japinli(at)hotmail(dot)com&gt;;
发送时间:&nbsp;2021年7月6日(星期二) 晚上7:04
收件人:&nbsp;"zwj"<757634191(at)qq(dot)com&gt;;
抄送:&nbsp;"pgsql-hackers"<pgsql-hackers(at)lists(dot)postgresql(dot)org&gt;;
主题:&nbsp;Re: Why is XLOG_FPI_FOR_HINT always need backups?

On Tue, 06 Jul 2021 at 17:58, zwj <757634191(at)qq(dot)com&gt; wrote:
&gt; Hi all,
&gt;
&gt; When I read the source code file src/backend/access/transam/xloginsert.c, I get something confused me.
&gt; In the function XLogSaveBufferForHint, the flags are always REGBUF_FORCE_IMAGE which means it is always need backups.
&gt; Is it right? Why do not check the full_page_writes?

The documentation [1] says:

------------------------------------------------------------------------------
wal_log_hints (boolean)
When this parameter is on, the PostgreSQL server writes the entire content of
each disk page to WAL during the first modification of that page after a
checkpoint, even for non-critical modifications of so-called hint bits.
------------------------------------------------------------------------------

Does that mean whether the full_page_writes enable or not, if the wal_log_hints
enabled, we always write the entire content of each disk page to WAL? If I'm
right, should we mention this in wal_log_hints?

[1] https://www.postgresql.org/docs/current/runtime-config-wal.html

--
Regrads,
Japin Li.
ChengDu WenWu Information Technology Co.,Ltd.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dean Rasheed 2021-07-06 12:50:58 Re: [PATCH] expand the units that pg_size_pretty supports on output
Previous Message Matthias van de Meent 2021-07-06 12:29:51 Re: Removing redundant check for transaction in progress in check_safe_enum_use