From: Andrew Gierth <andrew@tao11.riddles.org.uk>
To: Marcin Barczyński <mba.ogolny@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: BUG #15598: PostgreSQL Error Code is not reported when connection terminated due to idle-in-transaction timeout
Date: Mon, 21 Jan 2019 12:08:08 +0000
Message-ID: <87k1iy44fd.fsf@news-spur.riddles.org.uk> (raw)
In-Reply-To: <CAP3o3PdzM0BLmNBELA5wV6YoN_1yYBVdoOvz9kYbOuK-YQGFAw@mail.gmail.com>
References: <15598-e3fec9d8c5184936@postgresql.org>
<25293.1547829902@sss.pgh.pa.us>
<CAP3o3PdzM0BLmNBELA5wV6YoN_1yYBVdoOvz9kYbOuK-YQGFAw@mail.gmail.com>
>>>>> "Marcin" == Marcin Barczyński <mba.ogolny@gmail.com> writes:
Marcin> Unfortunately, it's not the problem of verbosity.
Marcin> The error code is printed properly in case of duplicate key
Marcin> violation. It seems that something is wrong with
Marcin> idle-in-transaction timeout on Windows:
I think this is domain-dependent or platform-dependent behavior of the
result of sending data on an already-closed connection.
On Ubuntu, were you using psql -h localhost, or psql with no host
parameter (which uses local-domain sockets by default, whereas with -h
localhost it uses TCP)?
When the server forces a connection to be closed like this, it writes
the ErrorResponse packet, and then closes the connection and ends the
backend process. Since psql does not expect data at that point, the
packet will (at best) remain buffered waiting to be read.
But when you do the next query, I am fairly sure that libpq will _write_
the new query to the connection before checking for any input. If the
connection is via TCP to localhost, that write may well result in an
immediate reset of the connection (since no process is available to read
from the other end), which may cause the buffered data to be discarded
before libpq can read it, so you never see it.
This isn't something we can reasonably fix, it's inherent to how the
network protocol implementations work. Only a client program that's
prepared to check for incoming data on an idle connection (which psql
does not) has any chance of reliably getting the error packet from a
forcibly closed connection (though clients that are not local to the
database host should _usually_ get it even if they do not check).
--
Andrew (irc:RhodiumToad)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-bugs@postgresql.org
Cc: andrew@tao11.riddles.org.uk, mba.ogolny@gmail.com, tgl@sss.pgh.pa.us
Subject: Re: BUG #15598: PostgreSQL Error Code is not reported when connection terminated due to idle-in-transaction timeout
In-Reply-To: <87k1iy44fd.fsf@news-spur.riddles.org.uk>
References: <15598-e3fec9d8c5184936@postgresql.org> <25293.1547829902@sss.pgh.pa.us> <CAP3o3PdzM0BLmNBELA5wV6YoN_1yYBVdoOvz9kYbOuK-YQGFAw@mail.gmail.com> <87k1iy44fd.fsf@news-spur.riddles.org.uk>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox