Re: Error on failed COMMIT

From: Dave Cramer <davecramer(at)postgres(dot)rocks>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: Andrew Dunstan <andrew(dot)dunstan(at)2ndquadrant(dot)com>, Tony Locke <tlocke(at)tlocke(dot)org(dot)uk>, Shay Rojansky <roji(at)roji(dot)org>, Bruce Momjian <bruce(at)momjian(dot)us>, Robert Haas <robertmhaas(at)gmail(dot)com>, Vik Fearing <vik(at)postgresfriends(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Vladimir Sitnikov <sitnikov(dot)vladimir(at)gmail(dot)com>, "Haumacher, Bernhard" <haui(at)haumacher(dot)de>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Error on failed COMMIT
Date: 2021-01-26 17:25:57
Message-ID: CADK3HHJwDQOVpoZY+p415wrg7CCJaowZCDSZTG67ib14h-=PpQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 26 Jan 2021 at 12:20, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> wrote:

> On Tue, 2021-01-26 at 11:09 -0500, Dave Cramer wrote:
> > On Tue, 26 Jan 2021 at 05:05, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
> wrote:
> >
> > > I wonder about the introduction of the new USER_ERROR level:
> > >
> > > #define WARNING_CLIENT_ONLY 20 /* Warnings to be sent to client
> as usual, but
> > > * never to the server log. */
> > > -#define ERROR 21 /* user error - abort transaction;
> return to
> > > +#define USER_ERROR 21
> > > +#define ERROR 22 /* user error - abort transaction;
> return to
> > > * known state */
> > > /* Save ERROR value in PGERROR so it can be restored when Win32
> includes
> > > * modify it. We have to use a constant rather than ERROR because
> macros
> > > * are expanded only when referenced outside macros.
> > > */
> > > #ifdef WIN32
> > > -#define PGERROR 21
> > > +#define PGERROR 22
> > > #endif
> > > -#define FATAL 22 /* fatal error - abort process */
> > > -#define PANIC 23 /* take down the other backends with
> me */
> > > +#define FATAL 23 /* fatal error - abort process */
> > > +#define PANIC 24 /* take down the other backends with
> me */
> > >
> > > I see that without that, COMMIT AND CHAIN does not behave correctly,
> > > since the respective regression tests fail.
> > >
> > > But I don't understand why. I think that this needs some more
> comments to
> > > make this clear.
> >
> > First off thanks for reviewing.
> >
> > The problem is that ereport does not return for any level equal to or
> above ERROR.
> > This code required it to return so that it could continue processing
>
> Oh, I see.
>
> After thinking some more about it, I think that COMMIT AND CHAIN would have
> to change behavior: if COMMIT throws an error (because the transaction was
> aborted), no new transaction should be started. Everything else seems
> fishy:
> the statement fails, but still starts a new transaction?
>
> I guess that's also at fault for the unexpected result status that
> Masahiko complained about in the other message.
>

I haven't had a look at the result status in libpq. For JDBC we don't see
that.
We throw an exception when we get this error report. This is very
consistent as the commit fails and we throw an exception

> So I think we should not introduce USER_ERROR at all. It is too much
> of a kluge: fail, but not really...
>

What we do now is actually worse as we do not get an error report and we
silently change commit to rollback.
How is this better ?

Dave

>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Vik Fearing 2021-01-26 17:34:34 Re: Error on failed COMMIT
Previous Message Laurenz Albe 2021-01-26 17:20:41 Re: Error on failed COMMIT