Re: SQLSTATE for Hot Standby cancellation

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: "Simon Riggs" <simon(at)2ndquadrant(dot)com>, "Andres Freund" <andres(at)anarazel(dot)de>, "Yeb Havinga" <yebhavinga(at)gmail(dot)com>
Cc: "Greg Smith" <greg(at)2ndquadrant(dot)com>, "Heikki Linnakangas" <heikki(dot)linnakangas(at)enterprisedb(dot)com>, "Robert Haas" <robertmhaas(at)gmail(dot)com>, "Bruce Momjian" <bruce(at)momjian(dot)us>, <pgsql-hackers(at)postgresql(dot)org>,"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: SQLSTATE for Hot Standby cancellation
Date: 2010-05-06 17:40:25
Message-ID: 4BE2B8B9020000250003133A@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Simon Riggs <simon(at)2ndQuadrant(dot)com> wrote:

> We don't have a retryable SQLSTATE, so perhaps we should document
> that serialization_failure and deadlock_detected are both
> retryable error conditions. As the above implies HS can throw some
> errors that are non-retyable, so we use ERRCODE_ADMIN_SHUTDOWN.

There is one SQLSTATE (40001 - serialization_failure) to indicate
that the transaction failed due to conflicts with concurrent
transactions. This is supposed to be used when there was no problem
with the transaction itself, were it to be run when nothing else is
running and the environment isn't failing. (For example, it isn't
the right code to use if you fail because your network connection is
broken or you're running out of disk space.) In my view it is a
mistake *not* to use it whenever concurrent transactions cause
failure; we can always use different error message text, details,
and hints to differentiate between the particular ways in which
concurrent transactions caused the failure.

The advantage of consistently using the standard value for this is
that there is software which recognizes this and automatically
retries the transaction from the beginning in a manner which is
transparent to the users and the application code. Our users never
see anything but a delay when hitting this; it's effectively the
same as blocking, with no application programmer effort needed.

Having a separate deadlock_detected SQLSTATE is arguably a bug. (In
fact, I have argued that; but haven't persuaded the community of
it.) Coming up with yet another SQLSTATE to indicate that there's
nothing wrong with the transaction except its timing in relation to
other transactions would, in my view, compound the error.

That said, our shop is resourceful enough (in more than one sense)
to overcome this if need be. I just don't see why the community
would choose to create barriers which cause failures for software
which would otherwise Just Work, and the corresponding programming
burden on shops using PostgreSQL to keep a list of "nothing really
wrong with the transaction, you can probably just reschedule it"
SQLSTATE values for the product.

-Kevin

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2010-05-06 18:47:10 Re: max_standby_delay considered harmful
Previous Message Tom Lane 2010-05-06 16:06:54 Re: Partitioning/inherited tables vs FKs