Re: crash recovery vs partially written WAL

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: pgsql-hackers(at)postgresql(dot)org, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Subject: Re: crash recovery vs partially written WAL
Date: 2020-12-31 19:13:07
Message-ID: 20201231191307.GJ22199@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Dec 30, 2020 at 12:52:46PM -0800, Andres Freund wrote:
> Hi,
>
> A question from a colleague made me wonder if there are scenarios where
> two subsequent crashes could lead to wrong WAL to be applied.
>
> Imagine the following scenario
> [ xlog page 1 ][ xlog page 2 ][ xlog page 3 ][ xlog page 4 ]
> ^flush ^write ^insert
>
> if the machine crashes in this moment, we could end up with a situation
> where page 1, 3, 4 made it out out to disk, but page 2 wasn't.

I don't see any flaw in your logic. Seems we have to zero out all
future WAL files, not just to the end of the current one, or at least
clear xlp_pageaddr on each future page.

--
Bruce Momjian <bruce(at)momjian(dot)us> https://momjian.us
EnterpriseDB https://enterprisedb.com

The usefulness of a cup is in its emptiness, Bruce Lee

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Victor Yegorov 2020-12-31 19:14:46 Re: Deleting older versions in unique indexes to avoid page splits
Previous Message Thomas Munro 2020-12-31 19:10:55 Re: pgbench: option delaying queries till connections establishment?