项目中需要用到分析功能,根据业务逻辑查询不同的数据表,然后再生成分析表。由于业务逻辑较多,查询耗时较长,第二天发现分析数据表没有生成。
异常信息如下:
[org.logicalcobwebs.proxool.db_master]#0001 was active for 322621 milliseconds and has been removed automaticaly. The Thread responsible was named 'Timer-0', and the last SQL it performed is 'select count(imei) as plusaskrun,count(distinct imei) as plusaskrundis from retvalue where wid = '10002004001701' and substring(time,1,10) ='2013-04-23' and serverplug!='' ; '. com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link failure Caused by: java.net.SocketException: socket closed at java.net.SocketInputStream.socketRead0(Native Method) at java.net.SocketInputStream.read(SocketInputStream.java:129) at com.mysql.jdbc.util.ReadAheadInputStream.fill(ReadAheadInputStream.java:113) at com.mysql.jdbc.util.ReadAheadInputStream.readFromUnderlyingStreamIfNecessary(ReadAheadInputStream.java:160) at com.mysql.jdbc.util.ReadAheadInputStream.read(ReadAheadInputStream.java:188) at com.mysql.jdbc.MysqlIO.readFully(MysqlIO.java:2452) at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2906)
找到原因发现是proxool将超过322621的连接池关闭了,并且不会重建,而整个流程在这个时间内还没有处理完所以报错。
修改proxool配置文件,给其添加maximum-active-time属性,默认配置为5分钟,将其修改为15分钟:
<maximum-connection-count>500</maximum-connection-count> <!--配置最大连接时间 15分钟--> <maximum-active-time>900000</maximum-active-time> <simultaneous-build-throttle>50</simultaneous-build-throttle> <house-keeping-test-sql>select 0</house-keeping-test-sql>