Re: Consider pipeline implicit transaction as a transaction block

From: Anthonin Bonnefoy <anthonin(dot)bonnefoy(at)datadoghq(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Consider pipeline implicit transaction as a transaction block
Date: 2024-11-04 09:42:36
Message-ID: CAO6_Xqq70__5pnWTf0hqE4gYsACNWYxzRUhikws6J3dK1cau9A@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, Nov 2, 2024 at 4:11 AM Michael Paquier <michael(at)paquier(dot)xyz> wrote:
> Now, here is a fancy case: SAVEPOINT and its two brothers. An error
> would be reported on HEAD if attempting a SAVEPOINT, complaining that
> we are not in a transaction block. The patch causes a different, more
> confusing, failure:
> FATAL: DefineSavepoint: unexpected state STARTED
>
> This is a bit user-unfriendly. I am not sure to see the point of
> supporting savepoints in this context, so perhaps we should just issue
> a cleaner error when we are under a XACT_FLAGS_PIPELINING? Reporting
> that we are not in a transaction block, while, well, we are in an
> implicit transaction block because of the use of pipelines is
> confusing. The new error is actually worse.

There's a possible alternative approach. Instead of checking the
XACT_FLAGS_PIPELINING flag in
CheckTransactionBlock/IsInTransactionBlock/PreventInTransactionBlock,
it is possible to switch the transaction state to
TBLOCK_IMPLICIT_INPROGRESS by reusing BeginImplicitTransactionBlock.
This transaction state is used to represent a transaction block
created by a multi statement query which is executed within the same
transaction, which is very similar to what's done with pipelining.

This allows the removal of the XACT_FLAGS_PIPELINING check in
IsInTransactionBlock and PreventInTransactionBlock since the
transaction state will correctly reflect the ongoing implicit block.
Additionally, it will reuse the same behaviour with regard to
SAVEPOINT and disallow them with a "SAVEPOINT can only be used in
transaction blocks" error.

Attachment Content-Type Size
v02-0001-Consider-pipeline-implicit-transaction-as-a-tran.patch application/octet-stream 3.6 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2024-11-04 09:47:27 Re: protocol-level wait-for-LSN
Previous Message Bertrand Drouvot 2024-11-04 09:35:36 Re: relfilenode statistics