Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Select via JPA (eclipselink) hangs on java.net.SocketInputStream.socketRead0(Native Method)
Select via JPA (eclipselink) hangs on java.net.SocketInputStream.socketRead0(Native Method) [message #671258] Tue, 17 May 2011 06:05 Go to next message
Sirdeaz  is currently offline Sirdeaz
Messages: 7
Registered: May 2011
Junior Member
Hi,

I've created an application which uses an executor to fetch data. At random times the application tends to stop from working. After the needed debugging (using jconsole) I found out that the threads hang on java.net.SocketInputStream.socketRead0(Native Method). I'm executing regular database fetches/selects, there are no updates involved. The data that is fetched is based on a view containing database links.

I've set up a <property name="javax.persistence.query.timeout" value="10"/> in the persistence.xml file. But it seems to be ignored (the behaviour reoccured after I set up the timeout). Threads weren't released after the 10s timeout.

It's a desktop app using:

- java: 1.6.0_18
- eclipselink: javax.persistence_2.0.1.v201006031150.jar
- oracle jdbc driver: ojdbc6.jar
- oracle db: oracle 11.1.0.7.0

I'm looking forward to your replies.

Regards

Frederik



[Updated on: Tue, 17 May 2011 06:46]

Report message to a moderator

Re: Select via JPA (eclipselink) hangs on java.net.SocketInputStream.socketRead0(Native Method) [message #671934 is a reply to message #671258] Thu, 19 May 2011 07:53 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Please include the full exception stack trace. Also the thread dump of all the relevant active threads would also be useful.

It could be a database deadlock, or some other type of failure.


James : Wiki : Book : Blog : Twitter
Re: Select via JPA (eclipselink) hangs on java.net.SocketInputStream.socketRead0(Native Method) [message #672565 is a reply to message #671934] Sat, 21 May 2011 15:35 Go to previous messageGo to next message
Sirdeaz  is currently offline Sirdeaz
Messages: 7
Registered: May 2011
Junior Member
Thanks for replying James.

I would find it weird to get a database deadlock while selecting values, unless oracle (11g) does lock stuff when selecting data via database links?

I will provide you with the full stacktrace when the error occurs again.
Re: Select via JPA (eclipselink) hangs on java.net.SocketInputStream.socketRead0(Native Method) [message #674204 is a reply to message #672565] Thu, 26 May 2011 02:46 Go to previous messageGo to next message
Sirdeaz  is currently offline Sirdeaz
Messages: 7
Registered: May 2011
Junior Member
Full stack dumps as requested:

Name: pool-2-thread-1
State: RUNNABLE
Total blocked: 2 Total waited: 84

Stack trace:
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.read(Unknown Source)
oracle.net.ns.Packet.receive(Packet.java:240)
oracle.net.ns.DataPacket.receive(DataPacket.java:92)
oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:172)
oracle.net.ns.NetInputStream.read(NetInputStream.java:117)
oracle.net.ns.NetInputStream.read(NetInputStream.java:92)
oracle.net.ns.NetInputStream.read(NetInputStream.java:77)
oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1034)
oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1010)
oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:588)
oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:791)
oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:866)
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1178)
oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3387)
oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3431)
- locked oracle.jdbc.driver.T4CConnection@13cd468
oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491)
org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:888)
org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:598)
org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:526)
org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:529)
org.eclipse.persistence.internal.sessions.IsolatedClientSession.executeCall(IsolatedClientSession.java:133)
org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:206)
org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:192)
org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:263)
org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:644)
org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2537)
org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2496)
org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:407)
org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1074)
org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:736)
org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1034)
org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:380)
org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1112)
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2909)
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1291)
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1273)
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1247)
org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:479)
org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:714)
be.carglass.purchaseassistant.persistence.FutureJobData.findByArtCode(FutureJobData.java:126)
be.carglass.purchaseassistant.gui.IncomingJobChartPanel$1.call(IncomingJobChartPanel.java:132)
be.carglass.purchaseassistant.gui.IncomingJobChartPanel$1.call(IncomingJobChartPanel.java:86)
java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
java.util.concurrent.FutureTask.run(Unknown Source)
java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
java.util.concurrent.FutureTask.run(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)


Name: pool-2-thread-2
State: RUNNABLE
Total blocked: 2 Total waited: 83

Stack trace:
java.net.SocketInputStream.socketRead0(Native Method)
java.net.SocketInputStream.read(Unknown Source)
oracle.net.ns.Packet.receive(Packet.java:240)
oracle.net.ns.DataPacket.receive(DataPacket.java:92)
oracle.net.ns.NetInputStream.getNextPacket(NetInputStream.java:172)
oracle.net.ns.NetInputStream.read(NetInputStream.java:117)
oracle.net.ns.NetInputStream.read(NetInputStream.java:92)
oracle.net.ns.NetInputStream.read(NetInputStream.java:77)
oracle.jdbc.driver.T4CMAREngine.unmarshalUB1(T4CMAREngine.java:1034)
oracle.jdbc.driver.T4CMAREngine.unmarshalSB1(T4CMAREngine.java:1010)
oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:588)
oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
oracle.jdbc.driver.T4CPreparedStatement.executeForDescribe(T4CPreparedStatement.java:791)
oracle.jdbc.driver.T4CPreparedStatement.executeMaybeDescribe(T4CPreparedStatement.java:866)
oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1178)
oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3387)
oracle.jdbc.driver.OraclePreparedStatement.executeQuery(OraclePreparedStatement.java:3431)
- locked oracle.jdbc.driver.T4CConnection@8da6f
oracle.jdbc.driver.OraclePreparedStatementWrapper.executeQuery(OraclePreparedStatementWrapper.java:1491)
org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeSelect(DatabaseAccessor.java:888)
org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.basicExecuteCall(DatabaseAccessor.java:598)
org.eclipse.persistence.internal.databaseaccess.DatabaseAccessor.executeCall(DatabaseAccessor.java:526)
org.eclipse.persistence.sessions.server.ServerSession.executeCall(ServerSession.java:529)
org.eclipse.persistence.internal.sessions.IsolatedClientSession.executeCall(IsolatedClientSession.java:133)
org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:206)
org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeCall(DatasourceCallQueryMechanism.java:192)
org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.executeSelectCall(DatasourceCallQueryMechanism.java:263)
org.eclipse.persistence.internal.queries.DatasourceCallQueryMechanism.selectAllRows(DatasourceCallQueryMechanism.java:644)
org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRowsFromTable(ExpressionQueryMechanism.java:2537)
org.eclipse.persistence.internal.queries.ExpressionQueryMechanism.selectAllRows(ExpressionQueryMechanism.java:2496)
org.eclipse.persistence.queries.ReadAllQuery.executeObjectLevelReadQuery(ReadAllQuery.java:407)
org.eclipse.persistence.queries.ObjectLevelReadQuery.executeDatabaseQuery(ObjectLevelReadQuery.java:1074)
org.eclipse.persistence.queries.DatabaseQuery.execute(DatabaseQuery.java:736)
org.eclipse.persistence.queries.ObjectLevelReadQuery.execute(ObjectLevelReadQuery.java:1034)
org.eclipse.persistence.queries.ReadAllQuery.execute(ReadAllQuery.java:380)
org.eclipse.persistence.queries.ObjectLevelReadQuery.executeInUnitOfWork(ObjectLevelReadQuery.java:1112)
org.eclipse.persistence.internal.sessions.UnitOfWorkImpl.internalExecuteQuery(UnitOfWorkImpl.java:2909)
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1291)
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1273)
org.eclipse.persistence.internal.sessions.AbstractSession.executeQuery(AbstractSession.java:1247)
org.eclipse.persistence.internal.jpa.EJBQueryImpl.executeReadQuery(EJBQueryImpl.java:479)
org.eclipse.persistence.internal.jpa.EJBQueryImpl.getResultList(EJBQueryImpl.java:714)
be.carglass.purchaseassistant.persistence.FutureJobData.findByArtCode(FutureJobData.java:126)
be.carglass.purchaseassistant.gui.IncomingJobChartPanel$1.call(IncomingJobChartPanel.java:132)
be.carglass.purchaseassistant.gui.IncomingJobChartPanel$1.call(IncomingJobChartPanel.java:86)
java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
java.util.concurrent.FutureTask.run(Unknown Source)
java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
java.util.concurrent.FutureTask.run(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
java.lang.Thread.run(Unknown Source)

This is an example of a possible stack trace. It appears to happen at random times. All queries are finetuned to run in less than 2 seconds, unless this behaviour occurs.

[Updated on: Thu, 26 May 2011 13:18]

Report message to a moderator

Re: Select via JPA (eclipselink) hangs on java.net.SocketInputStream.socketRead0(Native Method) [message #674821 is a reply to message #674204] Sat, 28 May 2011 14:09 Go to previous messageGo to next message
Sirdeaz  is currently offline Sirdeaz
Messages: 7
Registered: May 2011
Junior Member
After doing some more research I found out that the behaviour occurs after the application is left idle for a certain period of time.

The app keeps 2 db connections open during its entire lifetime. I've read that firewalls can close these connections down.

Can this be causing the behaviour described?

If so, what's the cleanest way to solve it?

I've tried adding (ENABLE=BROKEN) to the jdbc connection string.
I don't see setting the connection pool min size 0 as being a valid option (unless it's the preferred way to solve the issue).
Re: Select via JPA (eclipselink) hangs on java.net.SocketInputStream.socketRead0(Native Method) [message #675196 is a reply to message #674821] Mon, 30 May 2011 10:46 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

Odd that the JDBC driver hangs instead of failing when it gets timed out.
Normally you get a "connection reset by peer" error.

The "javax.persistence.query.timeout" option should work,
could you also try the,
"eclipselink.jdbc.timeout"
query hint on the specific query that is hanging, it could be an issue with the timeout not being applied.

I did find a link in a JDBC forum,
http://kr.forums.oracle.com/forums/thread.jspa?threadID=646577

You may be able to configure the timeout in your network or firewall as well.

Otherwise options are to use a keep alive thread to ping the connection, or set your min pool size to 0, or use a third party DataSource such as Oracle UCP that allows for connection timeouts and keep alive.


James : Wiki : Book : Blog : Twitter
Re: Select via JPA (eclipselink) hangs on java.net.SocketInputStream.socketRead0(Native Method) [message #675230 is a reply to message #675196] Mon, 30 May 2011 11:21 Go to previous message
Sirdeaz  is currently offline Sirdeaz
Messages: 7
Registered: May 2011
Junior Member
Thanks a lot for replying James.

I do find it rather weird that it's ignoring the timeout setting. I'll try applying eclipselink.jdbc.timeout as a queryhint.

I'll check out Oracle UCP as well.
Previous Topic:Progress/Openedge database
Next Topic:Create Canonical Metamodel without using any JPA/EclipseLink Annotations
Goto Forum:
  


Current Time: Fri Aug 22 00:02:57 EDT 2014

Powered by FUDForum. Page generated in 0.12480 seconds