Re: Reviewing freeze map code

From: Noah Misch <noah(at)leadboat(dot)com>
To: Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Andres Freund <andres(at)anarazel(dot)de>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, Michael Paquier <michael(dot)paquier(at)gmail(dot)com>, Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Reviewing freeze map code
Date: 2016-06-26 21:39:08
Message-ID: 20160626213908.GA1317196@tornado.leadboat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, Jun 21, 2016 at 10:59:25AM +1200, Thomas Munro wrote:
> On Fri, Jun 17, 2016 at 3:36 PM, Noah Misch <noah(at)leadboat(dot)com> wrote:
> > I agree the non-atomic, unlogged change is a problem. A related threat
> > doesn't require a torn page:
> >
> > AssignTransactionId() xid=123
> > heapam.c:3931 HeapTupleHeaderSetXmax(oldtup.t_data, 123);
> > some ERROR before heap_update() finishes
> > rollback; -- xid=123
> > some backend flushes the modified page
> > immediate shutdown
> > AssignTransactionId() xid=123
> > commit; -- xid=123
> >
> > If nothing wrote an xlog record that witnesses xid 123, the cluster can
> > reassign it after recovery. The failed update is now considered a successful
> > update, and the row improperly becomes dead. That's important.
>
> I wonder if that was originally supposed to be handled with the
> HEAP_XMAX_UNLOGGED flag which was removed in 11919160. A comment in
> the heap WAL logging commit f2bfe8a2 said that tqual routines would
> see the HEAP_XMAX_UNLOGGED flag in the event of a crash before logging
> (though I'm not sure if the tqual routines ever actually did that).

HEAP_XMAX_UNLOGGED does appear to have originated in contemplation of this
same hazard. Looking at the three commits in "git log -S HEAP_XMAX_UNLOGGED"
(f2bfe8a b58c041 1191916), nothing ever completed the implementation by
testing for that flag.

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message David Rowley 2016-06-27 01:17:10 Re: Rethinking representation of partial-aggregate steps
Previous Message David Rowley 2016-06-26 20:40:02 Re: Rethinking representation of partial-aggregate steps