Re: query against pg_locks leads to large memory alloc

From: Dave Owens <dave(at)teamunify(dot)com>
To: Kevin Grittner <kgrittn(at)ymail(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Merlin Moncure <mmoncure(at)gmail(dot)com>, Matheus de Oliveira <matioli(dot)matheus(at)gmail(dot)com>, postgres performance list <pgsql-performance(at)postgresql(dot)org>
Subject: Re: query against pg_locks leads to large memory alloc
Date: 2014-08-19 17:14:45
Message-ID: CA+OQrzgMRG3y5htc6SPyfT2wzo1xBJ=+xa84ok=bWMr3fHU3Rg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

On Tue, Aug 19, 2014 at 9:40 AM, Kevin Grittner <kgrittn(at)ymail(dot)com> wrote:
> Hmm, that's not outrageous. How about long-running transactions?
> Please check pg_stat_activity and pg_prepared_xacts for xact_start
> or prepared (respectively) values older than a few minutes. Since
> predicate locks may need to be kept until an overlapping
> transaction completes, a single long-running transaction can bloat
> the lock count.

I do see a handful of backends that like to stay IDLE in transaction
for minutes at a time. We are refactoring the application responsible
for these long IDLE times, which will hopefully reduce the duration of
their connections.

# select backend_start, xact_start, query_start, waiting,
current_query from pg_stat_activity where xact_start < now() -
interval '3 minutes';
backend_start | xact_start |
query_start | waiting | current_query
-------------------------------+-------------------------------+-------------------------------+---------+-----------------------
2014-08-19 09:48:00.398498-07 | 2014-08-19 09:49:19.157478-07 |
2014-08-19 10:03:04.99303-07 | f | <IDLE> in transaction
2014-08-19 09:38:00.493924-07 | 2014-08-19 09:53:47.00614-07 |
2014-08-19 10:03:05.003496-07 | f | <IDLE> in transaction
(2 rows)

... now() was 2014-08-19 10:03 in the above query. I do not see
anything in pg_prepared_xacts, we do not use two-phase commit.

> Also, could you show use the output from?:
>
> SELECT version();
version
---------------------------------------------------------------------------------------------------------------
PostgreSQL 9.1.13 on x86_64-unknown-linux-gnu, compiled by gcc (GCC)
4.4.7 20120313 (Red Hat 4.4.7-4), 64-bit
(1 row)

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Andres Freund 2014-08-19 17:17:10 Re: query against pg_locks leads to large memory alloc
Previous Message Kevin Grittner 2014-08-19 16:40:41 Re: query against pg_locks leads to large memory alloc