Solved

JDBC hangs on socketRead

Posted on 2002-07-12
8
959 Views
Last Modified: 2008-02-07
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
Comment
Question by:rpolocz
8 Comments
 
LVL 5

Expert Comment

by:fontaine
Comment Utility
Could you please post a piece of code that demonstrates the problem (the smaller the better), preferrably a standalone app. Thx.
0
 
LVL 1

Expert Comment

by:yourbutler
Comment Utility
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
 
LVL 1

Author Comment

by:rpolocz
Comment Utility
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
 
LVL 1

Expert Comment

by:yourbutler
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 1

Author Comment

by:rpolocz
Comment Utility
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
 
LVL 1

Author Comment

by:rpolocz
Comment Utility
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
 
LVL 2

Accepted Solution

by:
keithlong earned 500 total points
Comment Utility
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
 
LVL 35

Expert Comment

by:girionis
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now