Re: troubleshooting a database that keeps locking up

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jonathan Vanasco <postgres(at)2xlp(dot)com>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: troubleshooting a database that keeps locking up
Date: 2014-11-13 17:24:55
Message-ID: 3941.1415899495@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jonathan Vanasco <postgres(at)2xlp(dot)com> writes:
> I have a database that has started to constantly hang after a brief period of activity

> looking at `select * from pg_stat_activity;` I roughly see the following each time:

> process 1 | <IDLE>
> process 2 | <IDLE> in transaction
> process 3 | <IDLE> in transaction
> process 4 | <IDLE>
> process 5 | <IDLE>
> process 6 | <IDLE>
> process 7 | INSERT INTO table_a ........ RETURNING id

> Does anyone have tips on how I can troubleshoot this.

It's a reasonable bet that process 7 is blocked waiting for a lock that's
held by one of the idle-in-transaction processes. You could look into
pg_locks to confirm that.

> I was hoping there would be some way to show the history of the "<IDLE> in transaction" processes, but I couldn't find them.

No, PG doesn't track that. You could turn on log_statement = all and
then look to the postmaster log to see what those processes had been
doing. (You'll probably want to set log_line_prefix to at least %p
if you haven't already.)

regards, tom lane

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jonathan Vanasco 2014-11-13 19:44:22 Are there any downsides to using postgres' data directory on a dedicated drive/partition / filesystem?
Previous Message Jonathan Vanasco 2014-11-13 16:36:18 troubleshooting a database that keeps locking up