Re: mvcc catalo gsnapshots and TopTransactionContext - Mailing list pgsql-hackers

From Andres Freund
Subject Re: mvcc catalo gsnapshots and TopTransactionContext
Date
Msg-id 20130809141822.GP14729@alap2.anarazel.de
Whole thread Raw
In response to Re: mvcc catalo gsnapshots and TopTransactionContext  (Robert Haas <robertmhaas@gmail.com>)
List pgsql-hackers
On 2013-08-09 09:05:51 -0400, Robert Haas wrote:
> On Thu, Aug 8, 2013 at 1:28 PM, Andres Freund <andres@2ndquadrant.com> wrote:
> > Well. It isn't. At least not in general. The specific case triggered
> > here though are cache invalidations being processed which can lead to
> > the catalog being read (pretty crummy, but not easy to get rid
> > of). That's actually safe since before we process the invalidations we
> > have done:
> > 1) CurrentTransactionState->state = TRANS_ABORT
> > 2) RecordTransactionAbort(), marking the transaction as aborted in the
> >   clog
> > 3) marked subxacts as aborted
> > 3) ProcArrayEndTransaction() (for toplevel ones)
> >
> > Due to these any tqual stuff will treat the current (sub-)xact and it's
> > children as aborted. So the catalog lookups will use the catalog in a
> > sensible state.
> >
> > Now, one could argue that it's certainly not safe for anything but
> > xact.c itself to play such games. And would be pretty damn right. We
> > could add some flat to signal catcache.c to temporarily use
> > Assert(IsTransactionBlock()) instead of IsTransactionStmt() but that
> > seems overly complex. I think the danger of code doing stuff in an
> > aborted transaction isn't that big.
> >
> > This certainly deserves a good comment...
> 
> Do you want to propose something?

I can, but it will have to wait a couple of days. I am only still online
because my holiday plans didn't 100% work out and got delayed by a
day...

> I basically don't have a very good feeling about this.  Processing
> invalidations should invalidate stuff, not try to reread it.

I agree. But fixing that seems to require a good amount of surgery. The
problem is that currently we cannot know for sure some index doesn't
still use the index support infrastructure :(.

> You may
> be right that our MVCC snapshot is OK at the point invalidations are
> processed, but we don't know what caused the transaction to abort in
> the first place.

Well, we know it has been an ERROR and nothing worse. And that it
successfully longjmp'ed up the way to postgres.c or one of the PLs.

Greetings,

Andres Freund

-- Andres Freund                       http://www.2ndQuadrant.com/PostgreSQL Development, 24x7 Support, Training &
Services



pgsql-hackers by date:

Previous
From: Craig Ringer
Date:
Subject: Re: Proposal for XML Schema Validation
Next
From: Tom Lane
Date:
Subject: Re: Proposal for XML Schema Validation