Re: [HACKERS] Unlogged tables cleanup

From: Michael Paquier <michael(at)paquier(dot)xyz>
To: Robert Haas <robertmhaas(at)gmail(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Kuntal Ghosh <kuntalghosh(dot)2007(at)gmail(dot)com>, konstantin knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [HACKERS] Unlogged tables cleanup
Date: 2019-05-23 06:42:48
Message-ID: 20190523064248.GF5870@paquier.xyz
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, May 21, 2019 at 08:39:18AM -0400, Robert Haas wrote:
> Yes. I thought I had described it. You create an unlogged table,
> with an index of a type that does not smgrimmedsync(), your
> transaction commits, and then the system crashes, losing the _init
> fork for the index.

The init forks won't magically go away, except in one case for empty
routines not going through shared buffers.

The empty routines writing pages which do not go through shared
buffers still log them, so those pages could go away when the host
crashes, and a checkpoint completed before calling smgrimmedsync() and
after the page has been logged. Please note the logic in
spgbuildempty() as an example.

Then, empty routines going through shared buffers fill in one or more
buffers, mark it/them as empty, dirty it/them, log the page(s) and then
unlock the buffer(s). If a crash happens after the transaction
commits, so we would still have the init page in WAL, and at the end
of recovery we would know about it.

Or is there something in log_newpage_buffer()/log_newpage() I am
missing but you foresee?
--
Michael

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Paul A Jungwirth 2019-05-23 07:02:56 Re: docs about FKs referencing partitioned tables
Previous Message David Rowley 2019-05-23 05:45:23 Re: PostgreSQL 12 Beta 1 press release draft