pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Gnanakumar <gnanam@zoniac.com>
To: pgsql-admin@postgresql.org
Subject: Very long "<IDLE> in transaction" query
Date: Thu, 3 May 2012 15:48:35 +0530
Message-ID: <008101cd2916$1c023b20$5406b160$@com> (raw)

Hi,

Recently, in our Production server, we found a "single query" being held up
in "<IDLE> in transaction" for more than 19 hours using the following query:
select date_trunc('second', current_timestamp - query_start) as runtime,
datname as database_name, current_query from pg_stat_activity where
current_query != '<IDLE>' order by 1 desc

but we're clueless which was the root cause of this issue and still hunting.
As we know, query output doesn't show up the actual query/statement.

We then ran the 3rd query available from PostgreSQL Wiki - Lock Monitoring
http://wiki.postgresql.org/wiki/Lock_Monitoring  From query result output, I
could infer only the following but still not able to find out the real root
cause:
	1) 2 tables are involved (table1 and table2)
	2) Mostly table1's indexes are appearing in the output.

Pasted below result output containing only "<IDLE> in transaction".  For
security reasons, I've masked/renamed table names and index names in
"relname" column.  Though all index names are renamed to as
"table1_xxxxx_indx", all are different index names and not the same index.
Yes, we do have more than 30 indexes in table1.

Can somebody help me out what is going wrong/causing these "<IDLE> in
transaction"?

datname |            relname            | transactionid |      mode       |
granted | usename |             substr             |          query_start
|       age        | procpid 
---------+-------------------------------+---------------+-----------------+
---------+---------+--------------------------------+-----------------------
--------+------------------+---------
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx  		 |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table2                        |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_pk                     |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_idx              |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx_indx             |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx__indx            |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1                        |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb |                               |     668748028 | ExclusiveLock   |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx__indx            |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740
 prodndb | table1_xxxxx__indx            |               | AccessShareLock |
t       | dbuser  | <IDLE> in transaction          | 2012-05-01
14:56:53.617912-04 | 19:20:59.644261  |   14740

But no rows were returned for the 2nd query available in PostgreSQL Wiki -
Lock Monitoring.

We're running PostgreSQL v8.2.22 and pgpool v3.1.1 (only connection pooling
feature is used).

Regards,
Gnanam





view thread (10+ messages)  latest in thread

Message-ID: <008101cd2916$1c023b20$5406b160$@com>
Permalink:  ../008101cd2916$1c023b20$5406b160$@com/
Also on:    postgresql.org/message-id/008101cd2916$1c023b20$5406b160$@com

 · 

reply

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 using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: gnanam@zoniac.com
  Subject: Re: Very long "<IDLE> in transaction" query
  In-Reply-To: <008101cd2916$1c023b20$5406b160$@com>

* 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