nested-xacts cursors (was Re: Performance with new nested-xacts code)

Поиск
Список
Период
Сортировка
От Tom Lane
Тема nested-xacts cursors (was Re: Performance with new nested-xacts code)
Дата
Msg-id 26844.1088691548@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Performance with new nested-xacts code  (Alvaro Herrera <alvherre@dcc.uchile.cl>)
Ответы Re: nested-xacts cursors (was Re: Performance with new  (Kris Jurka <books@ejurka.com>)
Re: nested-xacts cursors (was Re: Performance with new nested-xacts code)  (Alvaro Herrera <alvherre@dcc.uchile.cl>)
Re: nested-xacts cursors (was Re: Performance with new  (Oliver Jowett <oliver@opencloud.com>)
Список pgsql-hackers
Alvaro Herrera <alvherre@dcc.uchile.cl> writes:
> Well, my opinion is that cursors and other resources should at least be
> usable from a inner subtransaction in its parent -- because if that
> can't be done we are wasting some of the benefits, because we can't just
> "stick everything in a subtransaction" to be able to retry if it fails.  
> It is a pity that we can't roll back FETCH or lo_close() but at least we
> can keep them declared/open across a subtransaction commit.

AFAICS we can't allow an inner transaction to use a cursor that was
declared in an outer transaction, because if the inner transaction fails
then it's not just a matter of the FETCH not rolling back; the
subtransaction abort will restore state in the bufmgr and other places
that is simply inconsistent with the state of the cursor's plantree.

If we don't restore bufmgr state at subxact commit, I think that it
would work to do
begin;    begin;    declare cursor c ...;    end; -- cursor, bufmgr state NOT changed herefetch from c;...

It seems though that we might have a lot of problems with figuring out
which subsystems ought to restore state at subxact commit and which not.

Another point is that this will NOT work:
begin;    begin;    declare cursor c ...;    end; -- cursor, bufmgr state NOT changed here
    begin;    fetch from c;    abort; -- oops, wrong state restored here

so the rule would have to be something like "cursors can only be
touched by the highest subxact nesting level they have ever been
visible to".  Yuck.
        regards, tom lane


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Performance with new nested-xacts code
Следующее
От: Justin Clift
Дата:
Сообщение: Re: Bug with view definitions?