Problem with error response message

From: Tatsuo Ishii <ishii(at)postgresql(dot)org>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Problem with error response message
Date: 2012-05-22 11:59:57
Message-ID: 20120522.205957.2166675381012052857.t-ishii@sraoss.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

ErrorResponse message from backend has some field type codes include:

S
Severity: the field contents are ERROR, FATAL, or PANIC (in an
error message), or WARNING, NOTICE, DEBUG, INFO, or LOG (in a
notice message), or a localized translation of one of
these. Always present.

C
Code: the SQLSTATE code for the error (see Appendix A). Not
localizable. Always present.

If severity is ERROR, current transaction is aborted but existing
session is continued. If it is FATAL or worse, backend disconnects the
current session, or even postmaster restarts all backends (which
results in session disconnection anyway). Cluster management tools
such as pgpool-II has to carefully handle the message because there's
big difference between just adborting transaction and disconnecting
session. In the former, pgpool just forwards the error message to
frontend, but for later, it should disconnect the session. For this
purpose, pgpool-II examines SQLSTAE code. Unfortunately some error
codes such as 40001(serialization_failure) comes with different
severities ERROR or FATAL.

Here are some examples:

./tcop/postgres.c- ereport(FATAL,
./tcop/postgres.c: (errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
./tcop/postgres.c- errmsg("terminating connection due to conflict with recovery"),
./tcop/postgres.c- errdetail_recovery_conflict()));

./commands/trigger.c- ereport(ERROR,
./commands/trigger.c: (errcode(ERRCODE_T_R_SERIALIZATION_FAILURE),
./commands/trigger.c- errmsg("could not serialize access due to concurrent update")));
./commands/trigger.c- if (!ItemPointerEquals(&update_ctid, &tuple.t_self))

So I tried to look into severity code to find if it is a fatal error
or not. Unfortunately it is almost impossible because it could be
localized. My question is, why we need to localize this? It shouldn't
be computer recognizable message?

Also I wonder why "conflict with recovery" generates same error code
as serialization error. For me it seems not very consistent
choice. IMO, we should assign different error code for at least brings
totally different effect to frontend: aborting transactions or
sessions.
--
Tatsuo Ishii
SRA OSS, Inc. Japan
English: http://www.sraoss.co.jp/index_en.php
Japanese: http://www.sraoss.co.jp

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message José Luis Tallón 2012-05-22 12:05:39 Re: Changing the concept of a DATABASE
Previous Message Robert Haas 2012-05-22 11:56:04 Re: Changing the concept of a DATABASE