Re: Statement timeout not working on broken connections with active queries

From: "Brendan O'Shea" <brendanoshea(at)comcast(dot)net>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: Statement timeout not working on broken connections with active queries
Date: 2006-12-14 03:46:42
Message-ID: 002001c71f32$d86fa610$0201a8c0@kendall.corp.akamai.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
> "Brendan O'Shea" <brendanoshea(at)comcast(dot)net> writes:
>> We have discovered a situation where the statement_timeout is not =
>> honored for broken connections. If a connection is in the process of =
>> returning results to the client and the connection is severed (for =
>> example, network cable on client is unplugged) then the query continues =
>> to run on the server even after the statement_timeout is exceeded.
>
> Well, the backend is blocked on a write() to the socket and cannot abort
> that without bollixing the connection completely (i.e., loss of message
> synchronization). So I think waiting until the TCP stack declares
> failure is an appropriate response. If you want faster TCP failure,
> see whether your TCP stack allows timeout adjustments.
>
> Note that the query is not "running" in the sense of consuming any
> meaningful CPU or I/O resources in this state ...
>
> regards, tom lane

I noticed something odd about the query that is still active on the severed
connection. If the statement_timeout on the query is exceeded and I send a
cancel signal then the query still stays active, it does not respond to
cancel or kill TERM signals. But if I send the cancel signal before the
statement timeout is exceeded on the severed connection then the query is
cancelled and the status goes back to 'idle'. Can this behavior be changed
so that the cancel signal works regardless of whether or not the statement
timeout has been exceeded? This would be useful so that we can free
up the locks used by the active query that are interfering with the vacuum
daemon.

Thanks,
Brendan

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Anton 2006-12-14 05:11:42 Re: index на таблицу с ~ 700 000 записей: чем занят постгрес???
Previous Message Gregory S. Williamson 2006-12-14 03:22:18 Re: a question on SQL