Re: Nested xact status?

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Nested xact status?
Date: 2004-07-24 14:33:12
Message-ID: 20040724143312.GA2049@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Cc'ed to hackers ...

On Sat, Jul 24, 2004 at 02:10:49PM -0400, Tom Lane wrote:
> > I think I am done with this part. Please review and apply it. The
> > attached patch is probably the same I posted to patches some days ago,
> > only updated with the latest commits.
>
> It looks pretty good, but one thing I don't much like is the static
> AbortToLevel variable. I am thinking it would be better to have a
> transaction state value that indicates "abort pending", and to have
> the Rollback command mark every transaction up to the savepoint with
> that state value, and then the transaction-end code responds to that.
> Any particular reason you didn't do it that way?

A previous discarded patch used the static var as means of setting an
abort point when a function was called. The idea was to close all
subtransactions opened within the function, so that the user wouldn't be
presented with subtransactions that the function failed to close. I
think this is still needed, of course.

I thought about adding something to the transaction state, but the
"abort pending" state didn't come to my mind. Yes, I think it's
cleaner.

> Would we potentially be losing any needed state? (ISTM all the
> transactions that could need to change would be in TRANS_INPROGRESS
> states, and so shifting them all to TRANS_PENDING_ABORT shouldn't lose
> any information. But it would likely be trickier if we tried to do it
> as a TBLOCK state.)

Note that we don't allow to start subtransactions in aborted state, so
all intermediate subtransactions have to be in (TBLOCK) in-progress
state anyway. (The only reason StartAbortedSubtransaction() survived in
this patch is to allow a subtransaction to error out while in
TBLOCK_BEGIN state -- not sure what should really happen here.)

I don't see a lot of value in using TRANS states as control mechanism;
rather they are there to make sure we only make valid transaction calls.

> I will look at this. One reason I'd like to have the "abort pending"
> xact state is that I think we may need to be able to control rollback
> from outside xact.c, and it'll probably be cleaner with that.

Cool. Thank you very much.

One thing I noticed is that there are several ways to call a function --
as a rangevar, through SPI, and as "normal" functions in the executor.
Most likely all of them need some kind of handling.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"No deja de ser humillante para una persona de ingenio saber
que no hay tonto que no le pueda enseñar algo." (Jean B. Say)

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alvaro Herrera 2004-07-24 15:03:51 Re: make LockRelation use top transaction ID
Previous Message Tom Lane 2004-07-24 14:22:55 Re: PreallocXlogFiles