public inbox for [email protected]
help / color / mirror / Atom feedRe: How to cleanup transaction after statement_timeout aborts a query?
2+ messages / 2 participants
[nested] [flat]
* Re: How to cleanup transaction after statement_timeout aborts a query?
@ 2024-09-08 13:01 Istvan Soos <[email protected]>
2024-09-08 13:41 ` Re: How to cleanup transaction after statement_timeout aborts a query? Laurenz Albe <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: Istvan Soos @ 2024-09-08 13:01 UTC (permalink / raw)
To: Laurenz Albe <[email protected]>; +Cc: [email protected]
On Sun, Sep 8, 2024 at 1:19 PM Laurenz Albe <[email protected]> wrote:
> ROLLBACK and COMMIT are working: they end the transaction.
I have this reproduction test, and ROLLBACK does fail:
https://github.com/isoos/postgresql-dart/pull/363/files#diff-4547e49b04ec8280fb8f4f1ebf695b77f9a2d9a...
I've checked and nothing else is sent on the protocol, yet, for the
rollback statement it gets the 25P02 error.
> It is the atomicity guarantee of database transactions: either all statements
> succeed, or all fail.
Yeah, I thought so, that's why I'm struggling to see what's missing.
> To handle the failure of a statement while allowing the transaction to proceed,
> you can use savepoints. But be warned: don't even think of setting a savepoint
> before each statement. That would affect statement performance severely.
As the writer of the client library, I don't have the luxury of
telling users they need to change their way, hence I'm looking for any
pointer on the protocol level.
Thanks,
Istvan
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: How to cleanup transaction after statement_timeout aborts a query?
2024-09-08 13:01 Re: How to cleanup transaction after statement_timeout aborts a query? Istvan Soos <[email protected]>
@ 2024-09-08 13:41 ` Laurenz Albe <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Laurenz Albe @ 2024-09-08 13:41 UTC (permalink / raw)
To: Istvan Soos <[email protected]>; +Cc: [email protected]
On Sun, 2024-09-08 at 15:01 +0200, Istvan Soos wrote:
> On Sun, Sep 8, 2024 at 1:19 PM Laurenz Albe <[email protected]> wrote:
> > ROLLBACK and COMMIT are working: they end the transaction.
>
> I have this reproduction test, and ROLLBACK does fail:
> https://github.com/isoos/postgresql-dart/pull/363/files#diff-4547e49b04ec8280fb8f4f1ebf695b77f9a2d9a...
>
> I've checked and nothing else is sent on the protocol, yet, for the
> rollback statement it gets the 25P02 error.
You must be doing something wrong then, because it works:
test=> START TRANSACTION;
START TRANSACTION
test=*> SELECT 1 / 0;
ERROR: division by zero
test=!> SELECT 42;
ERROR: current transaction is aborted, commands ignored until end of transaction block
test=!> SELECT 42;
ERROR: current transaction is aborted, commands ignored until end of transaction block
test=!> ROLLBACK;
ROLLBACK
test=>
>
> > To handle the failure of a statement while allowing the transaction to proceed,
> > you can use savepoints. But be warned: don't even think of setting a savepoint
> > before each statement. That would affect statement performance severely.
>
> As the writer of the client library, I don't have the luxury of
> telling users they need to change their way, hence I'm looking for any
> pointer on the protocol level.
I understand. But there is no way to influence this behavior.
Perhaps the best option for your library is not to try to "mask" the way PostgreSQL
behaves in this case. It is then up to the users of the library to do the right thing.
Yours,
Laurenz Albe
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2024-09-08 13:41 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-09-08 13:01 Re: How to cleanup transaction after statement_timeout aborts a query? Istvan Soos <[email protected]>
2024-09-08 13:41 ` Laurenz Albe <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox