Re: WAL consistency check facility

From: Kuntal Ghosh <kuntalghosh(dot)2007(at)gmail(dot)com>
To: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
Cc: Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Robert Haas <robertmhaas(at)gmail(dot)com>, Peter Geoghegan <pg(at)heroku(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Amit Kapila <amit(dot)kapila(at)enterprisedb(dot)com>
Subject: Re: WAL consistency check facility
Date: 2016-09-14 08:55:01
Message-ID: CAGz5QCKuyr98du3Nnbu97xpQNuXmQpAGawg3YWNb+PV0xz5Ltw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Sep 14, 2016 at 11:31 AM, Michael Paquier
<michael(dot)paquier(at)gmail(dot)com> wrote:
> On Wed, Sep 14, 2016 at 2:56 PM, Kuntal Ghosh
> <kuntalghosh(dot)2007(at)gmail(dot)com> wrote:
>> Master
>> ---------------
>> - If wal_consistency check is enabled or needs_backup is set in
>> XLogRecordAssemble(), we do a fpw.
>> - If a fpw is to be done, then fork_flags is set with BKPBLOCK_HAS_IMAGE,
>> which in turns set has_image flag while decoding the record.
>> - If a fpw needs to be restored during redo, i.e., needs_backup is true,
>> then bimg_info is set with BKPIMAGE_IS_REQUIRED_FOR_REDO.
>
> Here that should be if wal_consistency is true, no?
Nope. I'll try to explain using some pseudo-code:
XLogRecordAssemble()
{
....
include_image = needs_backup || wal_consistency[rmid];
if (include_image)
{
....
set XLogRecordBlockHeader.fork_flags |= BKPBLOCK_HAS_IMAGE;
if (needs_backup)
set XLogRecordBlockImageHeader.bimg_info
|= BKPIMAGE_IS_REQUIRED_FOR_REDO;
....
}
.....
}

XLogReadBufferForRedoExtended()
{
......
if (XLogRecHasBlockImage() && XLogRecHasBlockImageForRedo())
{
RestoreBlockImage();
....
return BLK_RESTORED;
}
......
}

checkConsistency()
{
....
if (wal_consistency[rmid] && !XLogRecHasBlockImage())
throw error;
.....
}

*XLogRecHasBlockImageForRedo() checks whether bimg_info is set with
BKPIMAGE_IS_REQUIRED_FOR_REDO.

For a backup image any of the followings is possible:
1. consistency should be checked.
2. page should restored.
3. both 1 and 2.

Consistency check can be controlled by a guc parameter. But, standby
should be conveyed whether an image should be restored. For that, we
have used the new flag.
Suggestions?

--
Thanks & Regards,
Kuntal Ghosh
EnterpriseDB: http://www.enterprisedb.com

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ashutosh Sharma 2016-09-14 09:15:35 Re: Write Ahead Logging for Hash Indexes
Previous Message Rajkumar Raghuwanshi 2016-09-14 07:58:39 Re: Declarative partitioning - another take