某人可以吗?告诉我什么可能导致此问题:
服务器不再执行任何操作:
server.network.http-listener-1.thread-pool.currentthreadcount-count = 500
server.network.http-listener-1.thread-pool.currentthreadsbusy-count = 500
日志中包含很多内容:
[#|2013-05-06T13:06:07.917+0200|WARNING|glassfish3.0.1|com.sun.grizzly.config.GrizzlyServiceListener|_ThreadID=16;_ThreadName=Thread-1;|Interrupting idle Thread: http-thread-pool-8083-(498)|#]
[#|2013-05-06T13:06:09.917+0200|WARNING|glassfish3.0.1|com.sun.grizzly.config.GrizzlyServiceListener|_ThreadID=16;_ThreadName=Thread-1;|Interrupting idle Thread: http-thread-pool-8083-(499)|#]
[#|2013-05-06T13:06:10.917+0200|WARNING|glassfish3.0.1|com.sun.grizzly.config.GrizzlyServiceListener|_ThreadID=16;_ThreadName=Thread-1;|Interrupting idle Thread: http-thread-pool-8083-(500)|#]
正常行为:
server.network.http-listener-1.thread-pool.currentthreadcount-count = 427
server.network.http-listener-1.thread-pool.currentthreadsbusy-count = 8
server.network.http-listener-1.connection-queue.countqueued1minuteaverage-count = 184
server.network.http-listener-1.connection-queue.countqueued5minutesaverage-count = 3014
server.network.http-listener-1.connection-queue.countqueued15minutesaverage-count = 10058
最佳答案
如果您的连接耗尽,这可能表明您的连接在使用后尚未关闭。如果没有看到打开/关闭数据库连接的实现,很难给出示例。但通常您希望确保在finally子句中关闭连接,我将在下面提供一个示例:
try {
//Some logic that reads/writes to the database
}catch (SQLException e) { //Rollback in case something goes wrong
try {
System.out.println("Rolling back current db transaction");
conn.rollback();
} catch (SQLException e1) {
System.out.println(e1);
}
}finally{ //Close the connection
conn.close();
System.out.println("DB connection is closed");
}
这样无论读写失败与否都会关闭数据库连接。如果您未能正确关闭这些连接,这些连接将保持打开状态(或超时,具体取决于您的设置),您最终将耗尽连接
关于java - Glassfish v3 突然阻塞并耗尽最大线程数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16397915/