postgres中的很多SHOW TRANSACTION ISOLATION LEVEL查询 [英] Lot of SHOW TRANSACTION ISOLATION LEVEL queries in postgres
问题描述
我正在使用Hibernate 4,PostgreSQL和C3P0。
I am using Hibernate 4, PostgreSQL and C3P0.
在我的Web应用程序中,一段时间后,我在数据库中收到多个 SHOW TRANSACTION ISOLATION LEVEL
查询,这是由于我服务器挂起。在我的代码中,我所有的连接均已正确关闭。
In my web application, after sometime I am getting multiple SHOW TRANSACTION ISOLATION LEVEL
queries in database due to which my server gets hang. In my code all my connections are properly closed.
是由于连接泄漏引起的吗?
Is it due to a connection leak?
推荐答案
您还应该检查每个查询的状态
,如果它是 idle
没问题。
You should also check the state
of each query, if it's idle
it's most likely nothing problematic.
pg_stat_activity
将显示每个打开的连接所执行的最后一个查询。 c3p0使用 SHOW事务隔离级别
保持连接打开(正常行为和预期行为)。
pg_stat_activity
will show last query that was executed by each open connection. And c3p0 uses SHOW TRANSACTION ISOLATION LEVEL
to keep the connection open (normal and expected behavior).
这是什么发生:
- 连接已打开
-
SHOW事务隔离级别
被执行以保持连接打开。 - 连接池将定期(例如每10分钟)发送此查询以保持连接打开。
- 这些查询显示在
pg_stat_activity
中,因为在某些情况下,这些查询是通过给定连接执行的最后一个查询。另外,由于此连接未处于有效使用状态,它们将显示为idle
- Connection is opened
SHOW TRANSACTION ISOLATION LEVEL
is executed to keep the connection open.- Connection pool will send this query periodically (for example every 10 minutes) to keep the connection open.
- Those queries show up in
pg_stat_activity
because in some cases those were the last queries executed via given connection. Also they will show up asidle
because this connection is not in active use
这篇关于postgres中的很多SHOW TRANSACTION ISOLATION LEVEL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!