# Interrupt task is already scheduled for the thread Thread[main,5,main] and the type SO_TIMEOUT

# 问题现象

环境:

  1. Linux服务器
  2. Oracle 11g, Oracle 19c
  3. JDBC Driver 18.3.0.0

异常

java.lang.IllegalStateException: Interrupt task is already scheduled for the thread Thread[Schedule18591,5,main] and the type SO_TIMEOUT
	at oracle.net.nt.TimeoutInterruptHandler.scheduleInterrupt(TimeoutInterruptHandler.java:75)
	at oracle.net.nt.TimeoutInterruptHandler.scheduleInterrupt(TimeoutInterruptHandler.java:93)
	at oracle.net.nt.TimeoutSocketChannel.scheduleInterrupt(TimeoutSocketChannel.java:239)
	at oracle.net.nt.TimeoutSocketChannel.connect(TimeoutSocketChannel.java:106)
	at oracle.net.nt.TimeoutSocketChannel.<init>(TimeoutSocketChannel.java:86)
	at oracle.net.nt.TcpNTAdapter.connect(TcpNTAdapter.java:188)
	at oracle.net.nt.ConnOption.connect(ConnOption.java:172)
	at oracle.net.nt.ConnStrategy.execute(ConnStrategy.java:508)
	at oracle.net.resolver.AddrResolution.resolveAndExecute(AddrResolution.java:521)
	at oracle.net.ns.NSProtocol.establishConnection(NSProtocol.java:660)
	at oracle.net.ns.NSProtocol.connect(NSProtocol.java:287)
	at oracle.jdbc.driver.T4CConnection.connect(T4CConnection.java:1481)
	at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:540)
	at oracle.jdbc.driver.PhysicalConnection.connect(PhysicalConnection.java:782)
	at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:39)
	at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:704)

后来又新的异常

java.io.FileNotFoundException: /data/tomcat/webapps/dsjyy/dist/favicon.ico (Too many open files)
	at java.base/java.io.FileInputStream.open0(Native Method)
	at java.base/java.io.FileInputStream.open(FileInputStream.java:219)
	at java.base/java.io.FileInputStream.<init>(FileInputStream.java:157)
	at org.apache.commons.io.FileUtils.openInputStream(FileUtils.java:299)
	at com.succez.commons.util.y.c(WebUtils.java:1202)
	at com.succez.commons.util.y.b(WebUtils.java:898)
	at com.succez.sys.mvc.StaticFileHandler.doGet(StaticFileHandler.java:100)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:626)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:733)
	at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
	at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
	at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)

web服务器上文件句柄已经超过允许的最大范围,奇怪的是cpu导出文件lsof -p却没有发现很多文件句柄,反而更多的是数据库连接。

# 异常原因

Oracle jdbc Driver 12.2.0.0 以上版本,有一个BUG:

当连接的url设置了oracle.jdbc.ReadTimeout参数,18.3版本会出the type SO_TIMEOUT异常,且会导致数据库资源无法释放

Using the JDBC driver 18.3 along with oracle.jdbc.ReadTimeout property, it is throwing an IllegalStateException and does not properly free up the database resources.

It causes a session leak on the database side, eventually hitting the maximum number of processes, which then prevents any new connection to the database.

# 解决办法

降级驱动,使用jdbc(12.1.0.2)的版本。

# 参考资料

  1. https://support.oracle.com/knowledge/Middleware/2561983_1.html (opens new window)
  2. https://stackoverflow.com/questions/60556300/weblogic-oracle-db-sqlexception-interrupt-task-is-already-scheduled-for-th (opens new window)
是否有帮助?
0条评论
评论