我在一台机器上运行两个网络应用程序,在另一台机器上运行一个数据库。(他们使用相同的数据库) 一个可以很好地运行,但是另一个总是在大约 4 小时后停机。
错误信息如下:
Error 2014-11-03 13:31:05,902 [http-bio-8080-exec-7] ERROR spi.SqlExceptionHelper - An I/O error occured while sending to the backend.
| Error 2014-11-03 13:31:05,904 [http-bio-8080-exec-7] ERROR spi.SqlExceptionHelper - This connection has been closed.
Postgresql 日志:
2014-10-26 23:41:31 CDT WARNING: pgstat wait timeout
2014-10-27 01:13:48 CDT WARNING: pgstat wait timeout
2014-10-27 03:55:46 CDT LOG: could not receive data from client: Connection timed out
2014-10-27 03:55:46 CDT LOG: unexpected EOF on client connection
谁造成了这个问题,应用还是数据库?还是网络?
最佳答案
原因:
此时很明显,闲置的 TCP 连接已经断开,但我们的应用程序仍假定它是打开的。空闲连接是指池中当前未被应用程序使用的连接。
经过一些搜索,我得出的结论是我的应用程序和数据库之间的网络防火墙在 1 小时后丢弃了空闲/过时的连接。这似乎是许多人面临的普遍问题。
解决方法:
在 grails 中,您可以在 DataSource.groovy 中设置它。
environments {
development {
dataSource {
//configure DBCP
properties {
maxActive = 50
maxIdle = 25
minIdle = 1
initialSize = 1
minEvictableIdleTimeMillis = 60000
timeBetweenEvictionRunsMillis = 60000
numTestsPerEvictionRun = 3
maxWait = 10000
testOnBorrow = true
testWhileIdle = true
testOnReturn = false
validationQuery = "SELECT 1"
}
}
}
}
关于PostgreSQL 异常 : “An I/O error occured while sending to the backend” ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26711512/