spring batch
jdk1.8
Oracle 12c
Linux
程序通过 java -jar -Djava.security.egd=file:/dev/./urandom xxx 的方式执行,
但是在跟数据库进行交互的时候,总会时不时的出现java.sql.SQLRecoverableException: IO Error: Connection reset 这类的异常,
通过lsof 命令
java 17459 xxxx 87r CHR 1,9 0t0 3667 /dev/urandom
java 17459 xxxx 88r CHR 1,9 0t0 3667 /dev/urandom
java 17459 xxxx 89r CHR 1,8 0t0 3666 /dev/random
java 17459 xxxx 90r CHR 1,8 0t0 3666 /dev/random
java 17459 xxxx 91r CHR 1,9 0t0 3667 /dev/urandom
java 17459 xxxx 92r CHR 1,9 0t0 3667 /dev/urandom
java 17459 xxxx 95r CHR 1,9 0t0 3667 /dev/urandom
相同的java进程,random和urandom都存在,想知道是不是这个random导致阻塞,影响了数据库Connection连接,有什么方法能避免吗?
谁能给提供一下调查方向也可以,先谢谢了。
遇到过同样问题,数据库连接失效后,自动恢复时不能恢复。
在application定义文件(application.yml)里追加以下定义试下。
(如果是application.xml,把格式改下)
#(boolean) The indication of whether objects will be validated before being borrowed from the pool.
#If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another.
#NOTE - for a true value to have any effect, the validationQuery or validatorClassName parameter must be set to a non-null string.
#In order to have a more efficient validation, see validationInterval. Default value is false
spring.datasource.test-on-borrow: true
#(String) The SQL query that will be used to validate connections from this pool before returning them to the caller.
#If specified, this query does not have to return any data, it just can't throw a SQLException.
#The default value is null. Example values are SELECT 1(mysql), select 1 from dual(oracle), SELECT 1(MS Sql Server)
spring.datasource.validation-query: SELECT 1 FROM DUAL