Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1021
  • Last Modified:

JDBC hangs on socketRead

I am running Oracle 8.1.7.4 on Red Hat Linux 7.2 smp.  When I connect through JDBC after a while it hangs as shown in the following thread dump

"jcp-21" prio=1 tid=0x0x84492c8 nid=0x7242 runnable [4e21c000..4e21d86c]
      at java.net.SocketInputStream.socketRead0(Native Method)
      at java.net.SocketInputStream.read(SocketInputStream.java:116)
      at oracle.net.ns.Packet.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.ttc7.MAREngine.unmarshalUB1(MAREngine.java:931)
      at oracle.jdbc.ttc7.MAREngine.unmarshalSB1(MAREngine.java:893)
      at oracle.jdbc.ttc7.Ocommoncall.receive(Ocommoncall.java:104)
      at oracle.jdbc.ttc7.TTC7Protocol.setAutoCommit(TTC7Protocol.java:538)
      - locked <0x447960f8> (a oracle.jdbc.ttc7.TTC7Protocol)
      at oracle.jdbc.driver.OracleConnection.setAutoCommit(OracleConnection.java:1220)
      - locked <0x44c400b0> (a oracle.jdbc.driver.OracleConnection)
      at oracle.jdbc.driver.OracleConnection.<init>(OracleConnection.java:478)
      at oracle.jdbc.pool.OraclePooledConnection.getConnection(OraclePooledConnection.java:292)
      - locked <0x447ebf18> (a oracle.jdbc.pool.OraclePooledConnection)
      at oracle.jdbc.pool.OracleConnectionCacheImpl.getConnection(OracleConnectionCacheImpl.java:302)
      - locked <0x447961e0> (a oracle.jdbc.pool.OracleConnectionCacheImpl)
      at oracle.jdbc.pool.OracleConnectionCacheImpl.getConnection(OracleConnectionCacheImpl.java:268)
      - locked <0x447961e0> (a oracle.jdbc.pool.OracleConnectionCacheImpl)
      at tkm.ConnectMgr.getCon(ConnectMgr.java:67)
      at tkm.beans.KnodeRep.getKnode(KnodeRep.java:152)
      at tkm.kn.KnavUserReqCrsCommand.execute(KnavUserReqCrsCommand.java:127)
      at tkm.kn.KnavServlet.service(KnavServlet.java:132)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1417)
      at allaire.jrun.session.JRunSessionService.service(JRunSessionService.java:1106)
      at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java:1271)
      at allaire.jrun.servlet.JRunRequestDispatcher.forward(JRunRequestDispatcher.java:89)
      at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1557)
      at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1547)
      at allaire.jrun.servlet.JvmContext.dispatch(JvmContext.java:364)
      at allaire.jrun.jrpp.ProxyEndpoint.run(ProxyEndpoint.java:388)
      at allaire.jrun.ThreadPool.run(ThreadPool.java:272)
      at allaire.jrun.WorkerThread.run(WorkerThread.java:75)


All the other threads are in the state "waiting for moniter entry" such as below:

"jcp-22" prio=1 tid=0x0x844aa58 nid=0x7243 waiting for monitor entry [4e29e000..4e29e86c]
      at oracle.jdbc.pool.OracleConnectionCacheImpl.getConnection(OracleConnectionCacheImpl.java:268)
      - waiting to lock <0x447961e0> (a oracle.jdbc.pool.OracleConnectionCacheImpl)
      at tkm.ConnectMgr.getCon(ConnectMgr.java:67)
      at tkm.beans.CourseIterationRep.getCoIter(CourseIterationRep.java:150)
      at tkm.kn.KnavOpenCrsCommand.execute(KnavOpenCrsCommand.java:83)
      at tkm.kn.KnavServlet.service(KnavServlet.java:132)
      at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
      at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1417)
      at allaire.jrun.session.JRunSessionService.service(JRunSessionService.java:1106)
      at allaire.jrun.servlet.JRunSE.runServlet(JRunSE.java:1271)
      at allaire.jrun.servlet.JRunRequestDispatcher.forward(JRunRequestDispatcher.java:89)
      at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1557)
      at allaire.jrun.servlet.JRunSE.service(JRunSE.java:1547)
      at allaire.jrun.servlet.JvmContext.dispatch(JvmContext.java:364)
      at allaire.jrun.jrpp.ProxyEndpoint.run(ProxyEndpoint.java:388)
      at allaire.jrun.ThreadPool.run(ThreadPool.java:272)
      at allaire.jrun.WorkerThread.run(WorkerThread.java:75)


It seems that all the other threads are waiting for a database connection, but because the moniter has that method locked by the thread that is apparently hung in the socketRead0 method, all the threads sit idle and wait.  I have verified this using JRun, Weblogic, and a simple java app without using an appserver.  I have reproduced this with IBM JVM 1.3.0, Sun JVM 1.3.1, 1.3.1_03, and 1.4.  I have also tried this with the following driver releases:
classes12.zip
classes12.jar
ojdbc14.jar

It is reproducable with both JDBC thin and OCI drivers.  

There are at least 2 messages about this on OTN, but no answers.  Can someone please help?  Thanks in advance!
0
rpolocz
Asked:
rpolocz
1 Solution
 
fontaineCommented:
Could you please post a piece of code that demonstrates the problem (the smaller the better), preferrably a standalone app. Thx.
0
 
yourbutlerCommented:
Are you closing your connections (sockets)?  After you open, if you don't close it (a connection) will stay open (locked) for a certain period of time which is set on the server.  I had this problem once and I think that was part of the solution.  We were using pooling and needed to increase our pool too since we had so many connections coming in.  If you are not pooling then you
0
 
rpoloczAuthor Commented:
We already checked that we are closing all the connections.  We are using Oracle's implementation of Connection Pooling, and have set the max at 400.  In monitoring connections during the test, we don't get above 250.  
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
yourbutlerCommented:
Oops, I meant that last one to be a comment.  Sorry about that.  There was some other thing that I cannot remember....something with the database though.  Seems like we did some upgrade or something with pooling.  
0
 
rpoloczAuthor Commented:
A test case is now available at ftp://guest:guest@65.114.254.21

I'm increasing the value of the question to 700 points, hoping for a quick resolution.

Thanks in advance!
0
 
rpoloczAuthor Commented:
Sorry, only lets me put 500 points on this question.  I added another question for 200 points at
http://www.experts-exchange.com/jsp/qManageQuestion.jsp?ta=java&qid=20323996

Use the test case to discover an answer and get 700 points total!
0
 
keithlongCommented:
Why do people assume this is a Socket problem or a Java problem.

It's a database problem and a lot of people have encountered it in the past. Obviously your problem will not reproduce on my system for this reason different versions of Oracle different patches.

Try running the same query through SQL-PLUS in my experience it will fail. It can be caused by a bug in the Oracle Software, or alternatively oracle is accessing damaged data.

http://www.orafaq.com/archive/comp.databases.oracle.server/2002/05/08/146319.htm

If you had, looked at the comp.databases.oracle threads, you would see someone has had something similar before.

I would advise, you to check your program against another version of Oracle if you have. If not attempt to patch your oracle version.

It is possible if you have an Oracle support contract, that this is the time to use it. I could be wrong, but I have been here in the past.

Hope this helps:
Regards

Keith Long
www.technogenius.co.uk
0
 
girionisCommented:
No comment has been added lately, so it's time to clean up this TA.

I will leave a recommendation in the Cleanup topic area that this question is:

- points to  keithlong

Please leave any comments here within the
next seven days.

PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER !

girionis
Cleanup Volunteer
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now