This relates to a previously unsolved post: here C3P0 seems to enter into a deadlock immediately after initializing connection pool on Heroku. The problem does not occur on my local postgres.
Here's the connection configuration from 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>
Here's the log. Note the hang for about one minute with 10 second cycles of "Running DeadlockDetector." Also note the invocation exception that follows:
[DEBUG] "com.mchange.v2.c3p0.impl.C3P0PooledConnectionPoolManager" 2015-07-05 07:12:57,851: Created new pool for auth, username (masked): 'sp******'.
[DEBUG] "com.mchange.v2.resourcepool.BasicResourcePool" 2015-07-05 07:12:57,851: acquire test -- pool size: 0; target_pool_size: 1; desired target? 1
...deleted some lines for sake of parsimony
[DEBUG] "com.mchange.v2.resourcepool.BasicResourcePool" 2015-07-05 07:12:59,132: Acquisition series terminated successfully. Decremented pending_acquires 1, attempts_remaining: 30
[DEBUG] "com.mchange.v2.resourcepool.BasicResourcePool" 2015-07-05 07:12:59,132: trace com.mchange.v2.resourcepool.BasicResourcePool@6293abcc [managed: 2, unused: 1, excluded: 0] (e.g. com.mchange.v2.c3p0.impl.NewPooledConnection@576ddf03)
[DEBUG] "com.mchange.v2.resourcepool.BasicResourcePool" 2015-07-05 07:12:59,132: decremented pending_acquires: 0
[DEBUG] "com.mchange.v2.resourcepool.BasicResourcePool" 2015-07-05 07:12:59,132: Acquisition series terminated successfully. Decremented pending_acquires [0], attempts_remaining: 30
[DEBUG] "com.mchange.v2.resourcepool.BasicResourcePool" 2015-07-05 07:12:59,132: trace com.mchange.v2.resourcepool.BasicResourcePool@6293abcc [managed: 2, unused: 1, excluded: 0] (e.g. 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 -- Running DeadlockDetector[Exiting. No pending tasks.]
...repeats every ten seconds
[DEBUG] "com.mchange.v2.async.ThreadPoolAsynchronousRunner" 2015-07-05 07:13:47,859: com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@45912fb9 -- Running DeadlockDetector[Exiting. No pending tasks.]
[INFO] "org.hibernate.dialect.Dialect" 2015-07-05 07:13:55,467: HHH000400: Using dialect: org.hibernate.dialect.PostgreSQLDialect
[INFO] "org.hibernate.engine.jdbc.internal.LobCreatorBuilder" 2015-07-05 07:13:55,472: HHH000424: Disabling contextual LOB creation as createClob() method threw error : java.lang.reflect.InvocationTargetException
[DEBUG] "com.mchange.v2.async.ThreadPoolAsynchronousRunner" 2015-07-05 07:13:55,576: com.mchange.v2.async.ThreadPoolAsynchronousRunner@6a01e23: Adding task to queue -- com.mchange.v2.resourcepool.BasicResourcePool$1RefurbishCheckinResourceTask@55b699ef