Killing "stuck" queries and preventing queries from getting "stuck"

From: Tim Uckun <timuckun(at)gmail(dot)com>
To: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Killing "stuck" queries and preventing queries from getting "stuck"
Date: 2010-09-27 23:41:36
Message-ID: AANLkTikfk-3tVf_NzwjLo4OS+vrcSsWXv4k7jhdoWOZ3@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

I have a situation where there are dozens of daemons hitting the same
postgres database. They all run different types of queries but each
daemon runs the same set of queries over and over again.

Sometimes some queries get "stuck" in that they run for hours and
hours. They never stop running. Killing the deamon does not stop the
query from running.

Once there are three of four of these "stuck" queries the database
slows down drastically.

Is there a way to tell postgres to stop any query that runs longer
than a specified amount of time? Say an hour?

Failing that what is a good strategy for detecting stuck queries and
killing them.

Thanks.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Grzegorz Jaśkiewicz 2010-09-28 00:22:13 Re: Deleting orphaned records (not exists is very slow)
Previous Message Tim Uckun 2010-09-27 23:37:23 Re: Deleting orphaned records (not exists is very slow)