Glassfish v3突然阻塞并耗尽最大线程

时间:2013-05-06 11:35:32

标签: java glassfish java-ee-6

可以s.b.告诉我是什么导致这个:

服务器不再执行任何操作:

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

1 个答案:

答案 0 :(得分:0)

如果连接用完,可能表示您的连接在使用后没有关闭。如果没有看到打开/关闭数据库连接的实现,很难给出一个例子。但通常你想确保在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");
}

无论读/写是否失败,都将关闭数据库连接。如果您无法正确关闭这些连接,这些连接将保持打开状态(或根据您的设置超时),最终将耗尽连接