Environment
Situation
[2016-03-15 08:15:19,931] WARN226956[Timer-0] (ThreadPoolAsynchronousRunner.java:698) - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@490c7448 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!
[2016-03-15 08:15:19,950] WARN226975[Timer-0]
(ThreadPoolAsynchronousRunner.java:714) -
com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@490c7448
-- APPARENT DEADLOCK!!! Complete Status:
Managed Threads: 3
Active Threads: 3
Active Tasks:
com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@1dd8154e
(C3P0PooledConnectionPoolManager-Helper Thread-#1)
com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@555ec330
(C3P0PooledConnectionPoolManager-Helper Thread-#2)
com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquireTask@4060b019
(C3P0PooledConnectionPoolManager-Helper Thread-#0)
Pending
Tasks:
com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquiretask@bc95a54
com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquiretask@504946d7
com.mchange.v2.resourcepool.BasicResourcePool$ScatteredAcquiretask@7ac9f66e
com.mchange.v2.resourcepool.BasicResourcePool$RefurbishCheckinResourceTask@6151eebc
com.mchange.v2.resourcepool.BasicResourcePool$RefurbishCheckinResourceTask@4a10aa8e
com.mchange.v2.resourcepool.BasicResourcePool$RefurbishCheckinResourceTask@c2d769f
Resolution
The threads were blocked on socket read and simply hung forever, neither succeeding nor failing with an Exception.
That's what happens in a c3p0 APPARENT DEADLOCK! -- the pool recovers by abandoning the stuck Threads.
The application still recovers, although potentially after a longer latency is observed as if the socket reads had thrown a prompt Exception.
Cause
C3P0 determines "apparent deadlocks" when a connection is acquired but not returned to the pool within the deadlock detection timeout.