BUG #11455: PQerrorMessage not reset after PQreset

Started by Nonameover 11 years ago5 messagesbugs
Jump to latest
#1Noname
postgresql-bklyn@sneakemail.com

The following bug has been logged on the website:

Bug reference: 11455
Logged by: Caleb Epstein
Email address: postgresql-bklyn@sneakemail.com
PostgreSQL version: 9.3.4
Operating system: Linux
Description:

I'm testing application logic to reconnect to my database server after a
connection failure. I'm using PQreset() and I notice that the
PQerrorMessage() result keeps growing after each failed reconnect.

For example, see belwo. My application log messages start with "Database".
The "... Resetting" message is followed by a call to PQreset(). The "FATAL"
messages are the strings returned to be by PQerrorMessage.

Database connection failed. Resetting.
Database reconnect failed: FATAL: terminating connection due to
administrator command
FATAL: terminating connection due to administrator command
FATAL: the database system is shutting down
Database connection unavailable. Cannot persist
Database connection failed. Resetting.
Database reconnect failed: FATAL: terminating connection due to
administrator command
FATAL: terminating connection due to administrator command
FATAL: the database system is shutting down
FATAL: the database system is shutting down

The next error will have 3 instances of "system is shutting down", and so
on.

Thanks!

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Noname (#1)
Re: BUG #11455: PQerrorMessage not reset after PQreset

postgresql-bklyn@sneakemail.com writes:

I'm testing application logic to reconnect to my database server after a
connection failure. I'm using PQreset() and I notice that the
PQerrorMessage() result keeps growing after each failed reconnect.

It's unlikely that anyone is going to look into this unless you provide
a self-contained test case (ie, a small program that reproduces the
misbehavior). It's too hard to guess exactly what you did.

regards, tom lane

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

#3Caleb Epstein
cae@bklyn.org
In reply to: Tom Lane (#2)
Re: BUG #11455: PQerrorMessage not reset after PQreset

Test program (C++0x) attached. Run it with a connection info string as
argv[1]. It should print a dot once per second while the DB connection is
OK, but will print the PQerrorMessage text when the connection fails, and
then will PQreset the connection. Each time it prints the error you can
see all the previous error content and the error buffer just keeps growing
and growing rather than resetting when PQreset is called.

If instead of calling "PQreset", one calls "PQfinish" and "PQconnectdb"
(e.g. change the call from "reset" to "reconnect" on line 39), you'll
(naturally) see just the most recent error.

On Fri, Sep 19, 2014 at 3:57 PM, Tom Lane tgl-at-sss.pgh.pa.us
|postgresql-bklyn| <uabn4z8tjt@sneakemail.com> wrote:

postgresql-bklyn@sneakemail.com writes:

I'm testing application logic to reconnect to my database server after a
connection failure. I'm using PQreset() and I notice that the
PQerrorMessage() result keeps growing after each failed reconnect.

It's unlikely that anyone is going to look into this unless you provide
a self-contained test case (ie, a small program that reproduces the
misbehavior). It's too hard to guess exactly what you did.

regards, tom lane

--
Caleb Epstein

Attachments:

libpq-error-cascade.cpptext/x-c++src; charset=US-ASCII; name=libpq-error-cascade.cppDownload
#4Caleb Epstein
cae@bklyn.org
In reply to: Tom Lane (#2)
Re: BUG #11455: PQerrorMessage not reset after PQreset

Here is the same logic in plain old C incase compiling or running C++0x
code is problematic for anyone.

On Fri, Sep 19, 2014 at 3:57 PM, Tom Lane tgl-at-sss.pgh.pa.us
|postgresql-bklyn| <uabn4z8tjt@sneakemail.com> wrote:

postgresql-bklyn@sneakemail.com writes:

I'm testing application logic to reconnect to my database server after a
connection failure. I'm using PQreset() and I notice that the
PQerrorMessage() result keeps growing after each failed reconnect.

It's unlikely that anyone is going to look into this unless you provide
a self-contained test case (ie, a small program that reproduces the
misbehavior). It's too hard to guess exactly what you did.

regards, tom lane

--
Caleb Epstein

Attachments:

libpq-error.ctext/x-csrc; charset=US-ASCII; name=libpq-error.cDownload
#5Heikki Linnakangas
heikki.linnakangas@enterprisedb.com
In reply to: Caleb Epstein (#4)
Re: BUG #11455: PQerrorMessage not reset after PQreset

On 09/20/2014 12:12 AM, Caleb Epstein wrote:

Here is the same logic in plain old C incase compiling or running C++0x
code is problematic for anyone.

Fixed, thanks for the report and test case!

- Heikki

--
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs