Re: Unlogged tables cleanup

From: Michael Paquier <michael(dot)paquier(at)gmail(dot)com>
To: konstantin knizhnik <k(dot)knizhnik(at)postgrespro(dot)ru>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Unlogged tables cleanup
Date: 2016-11-10 10:12:48
Message-ID: CAB7nPqTfpSDVoFDKKVk-4vVnA4pqZw7hcXQnA9XYA3HdKRsi8g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Thu, Nov 10, 2016 at 5:15 PM, Michael Paquier
<michael(dot)paquier(at)gmail(dot)com> wrote:
> Okay, so what happens is that the CREATE TABLESPACE record removes the
> tablespace directory and recreates a fresh one, but as no CREATE
> records are created for unlogged tables the init fork is not
> re-created. It seems to me that we should log a record to recreate the
> INIT fork, and that heap_create_with_catalog() is missing something.
> Generating a record in RelationCreateStorage() is the more direct way,
> and that actually fixes the issue. Now the comments at the top of it
> mention that RelationCreateStorage() should only be used to create the
> MAIN forknum. So, wouldn't a correct fix be to log this INIT record at
> the end of heap_create()?

Nah. Looking at the code the fix is quite obvious.
heap_create_init_fork() is checking for XLogIsNeeded() to decide if
the INIT forknum should be logged or not. But this is wrong, it needs
to be done unconditionally to ensure that the relation gets created at
replay.
--
Michael

Attachment Content-Type Size
unlogged-tbspace-fix.patch text/plain 501 bytes

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kyotaro HORIGUCHI 2016-11-10 10:33:06 Re: Floating point comparison inconsistencies of the geometric types
Previous Message Magnus Hagander 2016-11-10 10:00:55 Re: Remove the comment on the countereffectiveness of large shared_buffers on Windows