Re: idle_in_transaction_timeout - Mailing list pgsql-hackers

From Josh Berkus
Subject Re: idle_in_transaction_timeout
Date
Msg-id 538E3CB2.3040504@agliodbs.com
Whole thread Raw
In response to idle_in_transaction_timeout  (Vik Fearing <vik.fearing@dalibo.com>)
Responses Re: idle_in_transaction_timeout  (Tom Lane <tgl@sss.pgh.pa.us>)
Re: idle_in_transaction_timeout  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-hackers
Vik,

> When the timeout occurs, the backend commits suicide with a FATAL
> ereport.  I thought about just aborting the transaction to free the
> locks but decided that the client is clearly broken so might as well
> free up the connection as well.

Out of curiosity, how much harder would it have been just to abort the
transaction?  I think breaking the connection is probably the right
behavior, but before folks start arguing it out, I wanted to know if
aborting the transaction is even a reasonable thing to do.

Argument in favor of breaking the connection: most of the time, IITs are
caused by poor error-handling or garbage-collection code on the client
side, which has already abandoned the application session but hadn't let
go of the database handle.  Since the application is never going to
reuse the handle, terminating it is the right thing to do.

Argument in favor of just aborting the transaction: client connection
management software may not be able to deal cleanly with the broken
connection and may halt operation completely, especially if the client
finds out the connection is gone when they try to start their next
transaction on that connection.

My $0.019999999999998: terminating the connection is the preferred behavior.

> The same behavior can be achieved by an external script that monitors
> pg_stat_activity but by having it in core we get much finer tuning (it
> is session settable) and also traces of it directly in the PostgreSQL
> logs so it can be graphed by things like pgbadger.
> 
> Unfortunately, no notification is sent to the client because there's no
> real way to do that right now.

Well, if you abort the connection, presumably the client finds out when
they try to send a query ...

-- 
Josh Berkus
PostgreSQL Experts Inc.
http://pgexperts.com



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: json casts
Next
From: Jeff Janes
Date:
Subject: Re: Could not finish anti-wraparound VACUUM when stop limit is reached