Re: autonomous transactions - Mailing list pgsql-hackers

From Constantin S. Pan
Subject Re: autonomous transactions
Date
Msg-id 20160901164203.0e48330f@ppg
Whole thread Raw
In response to Re: autonomous transactions  (Greg Stark <stark@mit.edu>)
List pgsql-hackers
On Wed, 31 Aug 2016 14:46:30 +0100
Greg Stark <stark@mit.edu> wrote:

> On Wed, Aug 31, 2016 at 2:50 AM, Peter Eisentraut
> <peter.eisentraut@2ndquadrant.com> wrote:
> > - A API interface to open a "connection" to a background worker, run
> > queries, get results: AutonomousSessionStart(),
> > AutonomousSessionEnd(), AutonomousSessionExecute(), etc.  The
> > communication happens using the client/server protocol.
> 
> I'm surprised by the background worker. I had envisioned autonomous
> transactions being implemented by allowing a process to reserve a
> second entry in PGPROC with the same pid. Or perhaps save its existing
> information in a separate pgproc slot (or stack of slots) and
> restoring it after the autonomous transaction commits.
> 
> Using a background worker mean that the autonomous transaction can't
> access any state from the process memory. Parameters in plpgsql are a
> symptom of this but I suspect there will be others. What happens if a
> statement timeout occurs during an autonomous transaction? What
> happens if you use a pl language in the autonomous transaction and if
> it tries to use non-transactional information such as prepared
> statements?

I am trying to implement autonomous transactions that way. I
have already implemented suspending and restoring the parent
transaction state, at least some of it. The next thing on
the plan is the procarray/snapshot stuff. I think we should
reuse the same PGPROC for the autonomous transaction, and
allocate a stack of PGXACTs for the case of nested
autonomous transactions.

Solving the more general problem, running multiple
concurrent transactions with a single backend, may also be
interesting for some users. Autonomous transactions would
then be just a use case for that feature.

Regards,
Constantin Pan
Postgres Professional: http://www.postgrespro.com
The Russian Postgres Company



pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Choosing parallel_degree
Next
From: Tom Lane
Date:
Subject: Re: Postgres abort found in 9.3.11