From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-admin@postgresql.org
Subject: Re: Application hangs
Date: Mon, 1 Feb 2016 14:17:57 +0100
Message-ID: <n8nlu5$vji$1@ger.gmane.org> (raw)
In-Reply-To: <CALXoLqzy4Hh3Z+zAc1dNXX61QXgrq+t_K5uyCsuPSsf_+qH+Bw@mail.gmail.com>
References: <CALXoLqzy4Hh3Z+zAc1dNXX61QXgrq+t_K5uyCsuPSsf_+qH+Bw@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-admin>
Ankur Kaushik schrieb am 22.01.2016 um 04:47:
> We are facing problem in our Live server , Applications hangs after some time
>
> Please Let me know Is this database related or Application ?
>
> Process list shows as below
>
> postgres=# select count(*) from pg_stat_activity ;
> count
> -------
> 37
> (1 row)
>
>
> "*SELECT NULL AS TABLE_CAT*" and "*SHOW TRANSACTION ISOLATION LEVEL*", Type query increases as
>
If the session's state is "idle", the query shown in pg_stat_activity is the last query the session has run, not the current one (because the session isn't doing anything - it is idle).
As all sessions are idle, there isn't really anything wrong here.
Regarding the query itself, I already answered that in the other thread you opened, but I'll repeat it here as well:
Those queries look suspiciously like the query that is used by DatabaseMetaData.getTables().
I think the c3p0 connection pool has a pretty stupid default configuration where the validation query (that is used to check if a connection is still "alive") uses exactly that call. And I also think this is configured to be called each time a connection is returned to the pool - which imposes a huge (and unnecessary load) on the database server.
If that is the case you should configure a different validation query that is less invasive. Something like: preferredTestQuery="select 42", once that is configure c3p0 will no longer call the (expensive) DatabaseMetaData.getTables() method. It's one of the many reasons I don't like the c3p0 pool. I think Tomcat7's pool is a much better choice (I'm _not_ talking about DBCP, but about the new "native" pool introduced with Tomcat7)
I also recommend to _not_ test the connections when the pools hands them out or if they are returned, because those validation query will then put too much load on the database server.
It's better to configure the pool to validate the connections when they are idle, **not** when they are taken out or returned to the pool.
Again, how you configure this, depends on the pool you are using.
--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin
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: spam_eater@gmx.net
Subject: Re: Application hangs
In-Reply-To: <n8nlu5$vji$1@ger.gmane.org>
* 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