Re: Query on pg_stat_activity table got stuck

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: neeraj kumar <neeru(dot)cse(at)gmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org, pgsql-general(at)postgresql(dot)org
Subject: Re: Query on pg_stat_activity table got stuck
Date: 2019-05-06 21:33:06
Message-ID: 15877.1557178386@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin pgsql-general

neeraj kumar <neeru(dot)cse(at)gmail(dot)com> writes:
> We are using PG 10.6. We have one cron job that queries pg_stat_activity
> table to find out how many queries are running longer than X minutes and
> generate metrics.

> Query look like this :
> SELECT * FROM pg_stat_activity WHERE state='active'

> After some days, this query get stuck and doesn't finish. We tried to run
> this query manually and same result.

> We looked into pg_locks table and there this query is not blocked on any
> lock :
> https://justpaste.it/48rpe

Interesting. Can you get a stack trace to show where in the code it's
stuck?

https://wiki.postgresql.org/wiki/Generating_a_stack_trace_of_a_PostgreSQL_backend

regards, tom lane

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Siddharth Karandikar 2019-05-07 05:08:37 Re: Restoring from PostgreSQL 9.5 dump to 10 is super slow
Previous Message Pavan Kumar 2019-05-06 19:25:57 postgres wal log configuration question

Browse pgsql-general by date

  From Date Subject
Next Message Adam Brusselback 2019-05-06 21:48:33 Re: Postgres for SQL Server users
Previous Message Ravi Krishna 2019-05-06 20:44:52 Re: Postgres for SQL Server users