1

某人可以告诉我是什么原因导致的:

服务器不再做任何事情:

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
4

1 回答 1

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");
}

这样无论读/写是否失败,数据库连接都会关闭。如果您未能正确关闭这些连接,这些连接将保持打开状态(或超时,具体取决于您的设置),您最终将用完连接

于 2013-05-06T11:51:59.203 回答