【问题标题】:C3P0 connection pool stall with Heroku PostgresHeroku Postgres 的 C3P0 连接池停止
【发布时间】:2015-09-22 17:59:27
【问题描述】:

这与以前未解决的帖子有关:here 在 Heroku 上初始化连接池后,C3P0 似乎立即进入死锁。我的本地 postgres 上没有出现此问题。

这是来自 hibernate.hbm.xml 的连接配置

 <property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>



    <!-- Enable Hibernate's automatic session context management -->
    <property name="current_session_context_class">thread</property>


    <property name="hibernate.connection.url">jdbc:postgresql://myurl:5432/mydb?user=myusername&amp;password=myoassword&amp;sslfactory=org.postgresql.ssl.NonValidatingFactory&amp;ssl=true</property>
    <property name="hibernate.connection.driver_class">org.postgresql.Driver</property>
    <property name="hibernate.connection.username">myusername</property>
    <property name="hibernate.connection.password">mypassword</property>
    <property name="hibernate.archive.autodetection">class</property>
    <property name="hibernate.show_sql">true</property>
    <property name="hibernate.format_sql">true</property>
    <property name="hbm2ddl.auto">create</property>

    <!-- c3p0 connection pool settings -->
    <property name="hibernate.connection.provider_class">org.hibernate.service.jdbc.connections.internal.C3P0ConnectionProvider</property>
    <property name="hibernate.c3p0.min_size">1</property>
    <property name="hibernate.c3p0.max_size">2</property>
    <property name="hibernate.c3p0.timeout">1800</property>

这是日志。请注意在“运行死锁检测器”的 10 秒循环中挂起大约一分钟。还要注意下面的调用异常:

[DEBUG]“com.mchange.v2.c3p0.impl.C3P0PooledConnectionPoolManager”2015-07-05 07:12:57,851:为身份验证创建新池,用户名(屏蔽):'sp******' .

[DEBUG] "com.mchange.v2.resourcepool.BasicResourcePool" 2015-07-05 07:12:57,851:获取测试 -- 池大小:0;目标池大小:1;想要的目标? 1

...为简洁起见删除了一些行

[DEBUG] "com.mchange.v2.resourcepool.BasicResourcePool" 2015-07-05 07:12:59,132:采集系列成功终止。减少pending_acquires 1,尝试剩余:30

[DEBUG]“com.mchange.v2.resourcepool.BasicResourcePool”2015-07-05 07:12:59,132:跟踪 com.mchange.v2.resourcepool.BasicResourcePool@6293abcc [托管:2,未使用:1,排除: 0] (例如 com.mchange.v2.c3p0.impl.NewPooledConnection@576ddf03)

[DEBUG] "com.mchange.v2.resourcepool.BasicResourcePool" 2015-07-05 07:12:59,132: 递减的pending_acquires: 0

[DEBUG] "com.mchange.v2.resourcepool.BasicResourcePool" 2015-07-05 07:12:59,132:采集系列成功终止。递减pending_acquires [0],attempts_remaining:30

[DEBUG]“com.mchange.v2.resourcepool.BasicResourcePool”2015-07-05 07:12:59,132:跟踪 com.mchange.v2.resourcepool.BasicResourcePool@6293abcc [托管:2,未使用:1,排除: 0] (例如 com.mchange.v2.c3p0.impl.NewPooledConnection@576ddf03)

[DEBUG] "com.mchange.v2.async.ThreadPoolAsynchronousRunner" 2015-07-05 07:13:07,841: com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@45912fb9 -- 运行死锁检测器[退出。没有待处理的任务。]

...每十秒重复一次

[DEBUG]“com.mchange.v2.async.ThreadPoolAsynchronousRunner”2015-07-05 07:13:47,859:com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@45912fb9——运行死锁检测器[退出。没有待处理的任务。]

[INFO] "org.hibernate.dialect.Dialect" 2015-07-05 07:13:55,467: HHH000400: 使用方言:org.hibernate.dialect.PostgreSQLDialect

[INFO]“org.hibernate.engine.jdbc.internal.LobCreatorBuilder”2015-07-05 07:13:55,472:HHH000424:禁用上下文 LOB 创建作为 createClob() 方法引发错误:java.lang.reflect。调用目标异常

[DEBUG] "com.mchange.v2.async.ThreadPoolAsynchronousRunner" 2015-07-05 07:13:55,576: com.mchange.v2.async.ThreadPoolAsynchronousRunner@6a01e23: 将任务添加到队列——com.mchange。 v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask@55b699ef

【问题讨论】:

  • 将休眠日志切换为调试。在死锁检测器之前有一行:[DEBUG]“org.hibernate.engine.jdbc.cursor.internal.StandardRefCursorSupport”2015-07-05 07:39:21,781:尝试测量 JDBC REF_CURSOR 支持级别时出现意外错误:null

标签: java postgresql heroku c3p0


【解决方案1】:

答案其实已经贴出来了,解释的很好here

我在 hibernate.hbm.xml 中添加了以下内容

&lt;property name="temp.use_jdbc_metadata_defaults"&gt;false&lt;/property&gt;

【讨论】:

    猜你喜欢
    • 2018-11-26
    • 2013-08-20
    • 2012-01-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-08-09
    • 1970-01-01
    相关资源
    最近更新 更多