查询oracle卡住java.net.SocketInputStream.socketRead0

 程序运行一段时间后有一个线程总会卡住,通过jstack命令定位到卡住的线程如下

"WorkDispatchBolt:669-BoltExecutors" #94 prio=10 os_prio=0 tid=0x00007f9368017000 nid=0x206e1 runnable [0x00007f92fbefc000]
   java.lang.Thread.State: RUNNABLE
	at java.net.SocketInputStream.socketRead0(Native Method)
	at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
	at java.net.SocketInputStream.read(SocketInputStream.java:171)
	at java.net.SocketInputStream.read(SocketInputStream.java:141)
	at oracle.net.ns.Packet.receive(Unknown Source)
	at oracle.net.ns.DataPacket.receive(Unknown Source)
	at oracle.net.ns.NetInputStream.getNextPacket(Unknown Source)
	at oracle.net.ns.NetInputStream.read(Unknown Source)
	at oracle.net.ns.NetInputStream.read(Unknown Source)
	at oracle.net.ns.NetInputStream.read(Unknown Source)
	at oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1099)
	at oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1070)
	at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:478)
	at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:216)
	at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:955)
	at oracle.jdbc.driver.OracleStatement.executeMaybeDescribe(OracleStatement.java:1061)
	at oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:839)
	at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1133)
	at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3285)
	at oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3329)
	- locked <0x00000000d0e195f0> (a oracle.jdbc.driver.T4CPreparedStatement)
	- locked <0x00000000c04821d8> (a oracle.jdbc.driver.T4CConnection)
	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
	at org.apache.commons.dbcp.DelegatingPreparedStatement.executeQuery(DelegatingPreparedStatement.java:96)
	at org.springframework.jdbc.core.JdbcTemplate$1.doInPreparedStatement(JdbcTemplate.java:644)
	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:587)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:637)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:666)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:674)
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:714)

查询相关资料后,原因在于查询数据库时没有设置超时时间,由于网络等原因导致查询socket一直等待,需要增加超时时间配置

oracle.net.CONNECT_TIMEOUT=6000;oracle.jdbc.ReadTimeout=6000

所以修改spring配置文件增加配置


    
    
    
    
    
	
  

 

 

你可能感兴趣的:(研发技术)