Re: [GSoC2014] Patch ALTER TABLE ... SET LOGGED

From: Fabrízio de Royes Mello <fabriziomello(at)gmail(dot)com>
To: Andres Freund <andres(at)2ndquadrant(dot)com>
Cc: Christoph Berg <cb(at)df7cb(dot)de>, Pgsql Hackers <pgsql-hackers(at)postgresql(dot)org>, Stephen Frost <sfrost(at)snowman(dot)net>
Subject: Re: [GSoC2014] Patch ALTER TABLE ... SET LOGGED
Date: 2014-07-16 23:45:15
Message-ID: CAFcNs+qgPJFFvWPdK9pSnR6Z_o95QmpEnbzE6cdn=r0cS_wcqA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, Jul 16, 2014 at 7:26 PM, Andres Freund <andres(at)2ndquadrant(dot)com>
wrote:
>
> On 2014-07-16 20:53:06 +0200, Andres Freund wrote:
> > On 2014-07-16 20:25:42 +0200, Andres Freund wrote:
> > > Hi,
> > >
> > > I quickly looked at this patch and I think there's major missing
pieces
> > > around buffer management and wal logging.
> > >
> > > a) Currently buffers that are in memory marked as
> > > permanent/non-permanent aren't forced out to disk/pruned from
cache,
> > > not even when they're dirty.
> > > b) When converting from a unlogged to a logged table the relation
needs
> > > to be fsynced.
> > > c) Currently a unlogged table changed into a logged one will be
> > > corrupted on a standby because its contents won't ever be WAL
logged.
> >
> > Forget that, didn't notice that you're setting tab->rewrite = true.
>
> So, while that danger luckily isn't there I think there's something
> similar. Consider:
>
> CREATE TABLE blub(...);
> INSERT INTO blub ...;
>
> BEGIN;
> ALTER TABLE blub SET UNLOGGED;
> ROLLBACK;
>
> The rewrite will read in the 'old' contents - but because it's done
> after the pg_class.relpersistence is changed they'll all not be marked
> as BM_PERMANENT in memory. Then the ALTER TABLE is rolled back,
> including the relpersistence setting. Which will unfortunately leave
> pages with the wrong persistency setting in memory, right?
>

That means should I "FlushRelationBuffers(rel)" before change the
relpersistence?

Regards,

--
Fabrízio de Royes Mello
Consultoria/Coaching PostgreSQL
>> Timbira: http://www.timbira.com.br
>> Blog sobre TI: http://fabriziomello.blogspot.com
>> Perfil Linkedin: http://br.linkedin.com/in/fabriziomello
>> Twitter: http://twitter.com/fabriziomello

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2014-07-16 23:45:56 Re: Allow GRANT TRIGGER privilege to DROP TRIGGER (Re: Bug ##7716)
Previous Message Tom Lane 2014-07-16 23:08:40 Re: Question about src/timezone/zic.c