Home > Database > Mysql Tutorial > How to solve the deadlock caused by c3p0

How to solve the deadlock caused by c3p0

一个新手
Release: 2017-09-08 10:54:09
Original
2216 people have browsed it

The code was tested locally and was correct, so I put it on the external server for testing, and an error like this occurred.

com.mchange.v2.async.ThreadPoolAsynchronousRunner -466510
78 [Timer-18] WARN  com.mchange.v2.async.ThreadPoolAsynchronousRunner  - com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector@1c17bd4 -- APPARENT DEADLOCK!!! Creating emergency threads for unassigned pending tasks!
Copy after login

I was confused when I saw this, what should I do? Why did this happen? Condition?

My answer is:

Because the number of connections to the database is It is limited. Every time the application starts C3p0, it will occupy the database connection to fill the C3p0 connection pool. When the database resources are occupied, a deadlock will be reported because the shared resources cannot be obtained.

Change the maximum number of connections and the number of initial connections in the corresponding configuration file:

Before modification:

<property name="maxPoolSize" value="100" />  
<property name="initialPoolSize" value="2" />
Copy after login

After modification:

<property name="maxPoolSize" value="1" />  
<property name="initialPoolSize" value="1" />
Copy after login

Redeploy and run, ok!

The above is the detailed content of How to solve the deadlock caused by c3p0. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template