这与以前未解决的帖子有关: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&password=myoassword&sslfactory=org.postgresql.ssl.NonValidatingFactory&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秒。&#34;另请注意后面的调用异常:
[DEBUG]&#34; com.mchange.v2.c3p0.impl.C3P0PooledConnectionPoolManager&#34; 2015-07-05 07:12:58,851:为auth创建了新池,用户名(蒙面):&#39; sp ******&#39;。
[DEBUG]&#34; com.mchange.v2.resourcepool.BasicResourcePool&#34; 2015-07-05 07:12:57,551:获取测试 - 池大小:0; target_pool_size:1;期望的目标? 1
...为了简约而删除了一些行
[DEBUG]&#34; com.mchange.v2.resourcepool.BasicResourcePool&#34; 2015-07-05 07:12:59,132:收购系列成功终止。减少pending_acquires 1,attempts_remaining:30
[DEBUG]&#34; com.mchange.v2.resourcepool.BasicResourcePool&#34; 2015-07-05 07:12:59,132:trace com.mchange.v2.resourcepool.BasicResourcePool@6293abcc [managed:2,unused:1,excluded:0](例如com.mchange.v2.c3p0.impl.NewPooledConnection @ 576ddf03)
[DEBUG]&#34; com.mchange.v2.resourcepool.BasicResourcePool&#34; 2015-07-05 07:12:59,132:减少pending_acquires:0
[DEBUG]&#34; com.mchange.v2.resourcepool.BasicResourcePool&#34; 2015-07-05 07:12:59,132:收购系列成功终止。减少pending_acquires [0],attempts_remaining:30
[DEBUG]&#34; com.mchange.v2.resourcepool.BasicResourcePool&#34; 2015-07-05 07:12:59,132:trace com.mchange.v2.resourcepool.BasicResourcePool@6293abcc [managed:2,unused:1,excluded:0](例如com.mchange.v2.c3p0.impl.NewPooledConnection @ 576ddf03)
[DEBUG]&#34; com.mchange.v2.async.ThreadPoolAsynchronousRunner&#34; 2015-07-05 07:13:07,841:com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@45912fb9 - 运行DeadlockDetector [退出。没有待处理的任务。]
......每十秒重复一次
[DEBUG]&#34; com.mchange.v2.async.ThreadPoolAsynchronousRunner&#34; 2015-07-05 07:13:47,859:com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@45912fb9 - 运行DeadlockDetector [退出。没有待处理的任务。]
[INFO]&#34; org.hibernate.dialect.Dialect&#34; 2015-07-05 07:13:55,467:HHH000400:使用方言:org.hibernate.dialect.PostgreSQLDialect
[INFO]&#34; org.hibernate.engine.jdbc.internal.LobCreatorBuilder&#34; 2015-07-05 07:13:55,472:HHH000424:禁用上下文LOB创建为createClob()方法引发错误:java.lang.reflect.InvocationTargetException
[DEBUG]&#34; com.mchange.v2.async.ThreadPoolAsynchronousRunner&#34; 2015-07-05 07:13:55,576:com.mchange.v2.async.ThreadPoolAsynchronousRunner@6a01e23:将任务添加到队列 - com.mchange.v2.resourcepool.BasicResourcePool $ 1RefurbishCheckinResourceTask@55b699ef
答案 0 :(得分:1)
事实上,答案已经发布并且很好地解释了here:
我在hibernate.hbm.xml中添加了以下内容
<property name="temp.use_jdbc_metadata_defaults">false</property>
&#13;