JDBC client thread waits forever
Posted in 2014
Hello, I have a servlet application that communicates via JDBC with IDS. Periodically, the web server machine runs up to 100% CPU and stays there. The database server's CPU load is not excessive when this happens. Client machine (a web server, but "client" with respect to IDS): Linux (Centos 6) Java 1.7.0_55 Apache Tomcat 7.0.53 using AJP from Apache HTTPD 2.4.9 JDBC Driver: JDBC.4.10.JC2DE (I'm using only ifxjdbc.jar in my app) Database server machine: Linux (Centos 6) IDS 11.7 I've taken jstack traces from the running JVM on the web server during an episode of high CPU, and I see this thread lingering, long after any database accesses should be occurring: |"ajp-bio-8009-exec-16" daemon prio=10 tid=0x000000001d290800 nid=0x5dca in Object.wait() [0x00002ae859c31000] | java.lang.Thread.State: WAITING (on object monitor) | at java.lang.Object.wait(Native Method) | - waiting on <0x00000007d3c27a38> (a com.informix.jdbc.IfxSqliConnect) | at java.lang.Object.wait(Object.java:503) | at com.informix.jdbc.IfxSqliConnect.lockSession(IfxSqliConnect.java:4178) | - locked <0x00000007d3c27a38> (a com.informix.jdbc.IfxSqliConnect) | at com.informix.jdbc.IfxSqliConnect.lockSession(IfxSqliConnect.java:4170) | - locked <0x00000007d3c27a38> (a com.informix.jdbc.IfxSqliConnect) | at com.informix.jdbc.IfxSqli.executeRelease(IfxSqli.java:1940) | at com.informix.jdbc.IfxResultSet.f(IfxResultSet.java:1684) | at com.informix.jdbc.IfxResultSet.close(IfxResultSet.java:1619) | at com.informix.jdbc.IfxStatement.close(IfxStatement.java:506) | - locked <0x00000007df5deae8> (a com.informix.jdbc.IfxStatement) | ... lines that follow are my code, see below ... This is the only thread in my server stack dump containing the string "Ifx", and the only thread in the dump called from one of my methods. My code, at the point this thread is blocked, is here: | try (Connection jdbc = driver.openConnection(); | Statement stmt = jdbc.createStatement(); | ResultSet rset = stmt.executeQuery(sql)) { | | while (rset.next()) { | ... deal with one record... | } | | *** Thread stops here, closing try-with-resource resources *** | } catch (final SQLException ex) { | ... | } It seems to me that an Object.wait would not account for heavy CPU load, but this thread is not going away, even after 30+ minutes of no activity, so something seems amiss. I believe auto-close of the try-with-resource block will close the result set first, then the statement, but it looks like the driver is closing the result set again as part of the statement closure. As a side note, my application also uses an Oracle JDBC driver to communicate with a different Oracle server - several of my server stack threads are waiting inside "oracle.jdbc.*" packages, so it's possible the Oracle driver is where the CPU usage is coming from. Thanks in advance for any help.