Re: Error on failed COMMIT

From: Dave Cramer <davecramer(at)postgres(dot)rocks>
To: Vik Fearing <vik(at)postgresfriends(dot)org>
Cc: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Robert Haas <robertmhaas(at)gmail(dot)com>, Vladimir Sitnikov <sitnikov(dot)vladimir(at)gmail(dot)com>, Shay Rojansky <roji(at)roji(dot)org>, "Haumacher, Bernhard" <haui(at)haumacher(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: Error on failed COMMIT
Date: 2020-02-26 20:51:39
Message-ID: CADK3HHL=GmVPrkypE3n03ywoJ4=jpoZ8dSPf7b-OXVRM_bbpew@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 26 Feb 2020 at 13:46, Vik Fearing <vik(at)postgresfriends(dot)org> wrote:

> On 25/02/2020 12:11, Laurenz Albe wrote:
> > On Tue, 2020-02-25 at 13:25 +0530, Robert Haas wrote:
> >> On Tue, Feb 25, 2020 at 12:47 PM Vladimir Sitnikov
> >> <sitnikov(dot)vladimir(at)gmail(dot)com> wrote:
> >>> Noone suggested that "commit leaves the session in a transaction
> state".
> >>> Of course, every commit should terminate the transaction.
> >>> However, if a commit fails (for any reason), it should produce the
> relevant ERROR that explains what went wrong rather than silently doing a
> rollback.
> >>
> >> OK, I guess I misinterpreted the proposal. That would be much less
> >> problematic -- any driver or application that can't handle ERROR in
> >> response to an attempted COMMIT would be broken already.
> >
> > I agree with that.
> >
> > There is always some chance that someone relies on COMMIT not
> > throwing an error when it rolls back, but I think that throwing an
> > error is actually less astonishing than *not* throwing one.
> >
> > So, +1 for the proposal from me.
>
> I started this thread for some discussion and hopefully a documentation
> patch. But now I have moved firmly into the +1 camp. COMMIT should
> error if it can't commit, and then terminate the (aborted) transaction.
> --
> Vik Fearing
>

OK, here is a patch that actually doesn't leave the transaction in a failed
state but emits the error and rolls back the transaction.

This is far from complete as it fails a number of tests and does not cover
all of the possible paths.
But I'd like to know if this is strategy will be acceptable ?
What it does is create another server error level that will emit the error
and return as opposed to not returning.
I honestly haven't given much thought to the error message. At this point I
just want the nod as to how to do it.

Attachment Content-Type Size
0001-change-commit-semantics-to-throw-an-error-and-then-r.patch application/octet-stream 3.0 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message legrand legrand 2020-02-26 21:10:46 Re: WIP: Aggregation push-down
Previous Message Alexey Kondratov 2020-02-26 20:45:05 Re: [Patch] pg_rewind: options to use restore_command from recovery.conf or command line