Re: Lock problem

From: Merlin Moncure <mmoncure(at)gmail(dot)com>
To: Igor Neyman <ineyman(at)perceptron(dot)com>
Cc: Victor Sterpu <victor(at)caido(dot)ro>, PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Lock problem
Date: 2014-04-02 21:57:09
Message-ID: CAHyXU0zQyrTWMJ2xTrc8um0=NoiZq9Sa7TpfF_epMugGbON9=w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, Apr 2, 2014 at 3:01 PM, Igor Neyman <ineyman(at)perceptron(dot)com> wrote:
>
>
>> -----Original Message-----
>> From: pgsql-general-owner(at)postgresql(dot)org [mailto:pgsql-general-
>> owner(at)postgresql(dot)org] On Behalf Of Victor Sterpu
>> Sent: Wednesday, April 02, 2014 2:25 PM
>> To: Victor Sterpu; Merlin Moncure
>> Cc: PostgreSQL General
>> Subject: Re: [GENERAL] Lock problem
>>
>> I'm sure is not right, but is a there a server side solution for such sitations?
>> A configuration - timeout for idle transactions.
>>
>
> I don't think PG has such configuration parameter.
> But, you could easily write a function (say in PgPlSQL) and run it on schedule, where you could check "ILE IN TRANSACTDION" session and compare their start_time to system time, and then based on your criteria you could kill suspect session/transaction.
> But this could be dangerous; some long-running transactions could be perfectly valid.

I'd look for 'Idle In Transaction' backends that have
clock_timestamp() - state_change > x, where x is the maximum amount of
time your application does stuff between queries while in transaction.
Generally, x should never be more than about 10 seconds or so...or if
it is, it's advisable to restructure your application so that more
preprocessing is done before grabbing the transaction initially. In
fact, for well written applications, seeing 'idle in transaction'
should be quite exceptional.

merlin

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Greg Sabino Mullane 2014-04-02 22:07:34 Re: libpq - lack of support to set the fetch size
Previous Message Bret Stern 2014-04-02 21:55:19 Re: SSD Drives