dbcp 连接池不合理的锁导致连接耗尽解决方案(3)

java.lang.Thread.State: RUNNABLE at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:129) at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:112) at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:159) at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:187) - locked <0x0000000715a9ce70> (a com.mysql.jdbc.util.ReadAheadInputStream) at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:3140) at com.mysql.jdbc.MysqlIO.readPacket(MysqlIO.java:597) at com.mysql.jdbc.MysqlIO.doHandshake(MysqlIO.java:1085) at com.mysql.jdbc.ConnectionImpl.coreConnect(ConnectionImpl.java:2494) at com.mysql.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:2527) at com.mysql.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:2309)

这个是dbcp1.x版本在创建新的连接对象时会把整个连接工厂类对象锁了,一旦创建过程中发生阻塞就会导致整个池都死掉。这个问题很大。

解决方案,升级dbcp2.x版本或tomcat jdbc或druid连接池,推荐druid连接池,功能强大自带监控。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wzjxzp.html