-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 
Author Message
 Post subject: InterruptedIOException
PostPosted: Sun May 02, 2004 9:27 pm 
Newbie

Joined: Sat May 01, 2004 2:13 am
Posts: 5
Location: Wollongong/Australia
Hello,

We have been using Hibernate in a project for a while and it has been working fine. However we recently introduced a few additional classes to send emails and SMS(Using a HTTP GET to an external SMS gateway) messages . Since this has happened we intermittently get an InterruptedIOException thrown. At the end of this message I have attached the stack trace. There are multiple threads accessing the database through hibernate.

* Should it be safe to access hibernate using multiple threads?
* Should we just catch this exception and retry?
* Any idea what sorts of things could cause this?

I was unable to reproduce this problem with a small example, if you require any additional information please let me know.
Thanks in advance for any help, Brendon.


[java] java.io.InterruptedIOException
[java] MESSAGE: Operation interrupted

[java] STACKTRACE:

[java] java.io.InterruptedIOException: Operation interrupted
[java] at java.net.SocketInputStream.socketRead0(Native Method)
[java] at java.net.SocketInputStream.read(SocketInputStream.java:129)
[java] at java.io.BufferedInputStream.fill(BufferedInputStream.java:191)
[java] at java.io.BufferedInputStream.read(BufferedInputStream.java:209)
[java] at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:1449)
[java] at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:1826)
[java] at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1098)
[java] at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1192)
[java] at com.mysql.jdbc.Connection.execSQL(Connection.java:2051)
[java] at com.mysql.jdbc.PreparedStatement.executeQuery(PreparedStatement.java:1496)
[java] at net.sf.hibernate.impl.BatcherImpl.getResultSet(BatcherImpl.java:87)
[java] at net.sf.hibernate.loader.Loader.getResultSet(Loader.java:795)
[java] at net.sf.hibernate.loader.Loader.doQuery(Loader.java:189)
[java] at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:133)
[java] at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:910)
[java] at net.sf.hibernate.loader.Loader.loadCollection(Loader.java:885)
[java] at net.sf.hibernate.loader.CollectionLoader.initialize(CollectionLoader.java:69)
[java] at net.sf.hibernate.collection.AbstractCollectionPersister.initialize(AbstractCollectionPersister.java:284)
[java] at net.sf.hibernate.impl.SessionImpl.initializeCollection(SessionImpl.java:3226)
[java] at net.sf.hibernate.collection.PersistentCollection.forceInitialization(PersistentCollection.java:340)
[java] at net.sf.hibernate.impl.SessionImpl.initializeNonLazyCollections(SessionImpl.java:3089)
[java] at net.sf.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:138)
[java] at net.sf.hibernate.loader.Loader.doList(Loader.java:950)
[java] at net.sf.hibernate.loader.Loader.list(Loader.java:941)
[java] at net.sf.hibernate.hql.QueryTranslator.list(QueryTranslator.java:834)
[java] at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1512)
[java] at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1491)
[java] at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1487)
[java] at com.nortelnetworks.convene.base.persistence.DataAccess.findObject(DataAccess.java:172)
[java] at com.nortelnetworks.convene.base.persistence.DataAccess.findObject(DataAccess.java:145)
[java] at com.nortelnetworks.convene.base.persistence.DataAccess.fetch(DataAccess.java:267)
[java] at com.nortelnetworks.convene.app.access.GenericAccessMgr.get(GenericAccessMgr.java:57)
[java] at com.nortelnetworks.convene.app.access.UserMgr.get(UserMgr.java:15)
[java] at com.nortelnetworks.convene.app.access.NotificationMgr.sendNbpEvent(NotificationMgr.java:152)
[java] at com.nortelnetworks.convene.app.access.NotificationMgr.sendNbpEvent(NotificationMgr.java:119)
[java] at com.nortelnetworks.convene.app.data.Nbp.deploy(Nbp.java:77)
[java] at com.nortelnetworks.convene.app.nbp.NbpDeployTask.deploy(NbpDeployTask.java:96)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[java] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[java] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[java] at java.lang.reflect.Method.invoke(Method.java:494)
[java] at com.nortelnetworks.convene.base.scheduler.TimerEntry.execute(TimerEntry.java:45)
[java] at com.nortelnetworks.convene.base.scheduler.Scheduler.run(Scheduler.java:128)
[java] at java.lang.Thread.run(Thread.java:566)


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 03, 2004 6:40 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hibernate is ofcourse suitable in multi thread environments. The only thing you have to know about that is that session is not thread-safe and thus should be acessed in 1 thread at a time.
There is something like reconnect=true for mysql drivers, check the forum on that subject

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Mon May 03, 2004 10:28 pm 
Newbie

Joined: Sat May 01, 2004 2:13 am
Posts: 5
Location: Wollongong/Australia
We are currently using the Session with a LocalThread<Session> so that there is a single session for each thread.

I modified the config to look as follows:
<property name="connection.url">jdbc:mysql://localhost/convene?autoReconnect=true</property>

and it has probably fixed another issue that we were having where after long periods of time the SQL database connection was lost, however it didn't help the InterruptedIOException.

I was just reading the following link:

http://lists.mysql.com/java/6301

I am not sure about the internals of hibernate and how it accesses MySQL, but what is mentioned in the above link seems like it could be the problem i am having. Once the exception occurs we are unable to use the database from then on as it just keeps throwing the exception each time we try to access it.

Thanks, Brendon.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 04, 2004 4:33 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Wich connection pool do you use.
Prefer using :
- your app server connection pooling
- one of the provided connection pool (c3P0, proxool, etc...)

Don't use the Hibernate built-in connection pool for production use.

_________________
Emmanuel


Top
 Profile  
 
 Post subject: Resolved
PostPosted: Wed May 05, 2004 6:53 pm 
Newbie

Joined: Sat May 01, 2004 2:13 am
Posts: 5
Location: Wollongong/Australia
After a while of debugging i have found the source of the problem. Basically another thread was calling interrupt on the thread accessing hibernate while it was requesting information from the database and not only when it was sleeping. So the issues is solved.

I still however do not understand why future queries to the database through hibernate failed after this occurred.

Thanks for the help and suggestions.
Brendon.


Top
 Profile  
 
 Post subject:
PostPosted: Thu May 06, 2004 5:50 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Because a correct connection pool implementation should check that before retrieving a connection

_________________
Emmanuel


Top
 Profile  
 
 Post subject: How to set the connection pool.
PostPosted: Thu May 06, 2004 7:31 pm 
Newbie

Joined: Sat May 01, 2004 2:13 am
Posts: 5
Location: Wollongong/Australia
We have been using the default connection pooling up to date. I added the following lines to the hibernate.cfg.xml file.

<property name="hibernate.c3p0.minPoolSize">5</property>
<property name="hibernate.c3p0.maxPoolSize">20</property>
<property name="hibernate.c3p0.timeout">1800</property>
<property name="hibernate.c3p0.max_statement">50</property>

Is that all that is required to set connection pooling to use c3p0?

Thanks, Brendon.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 07, 2004 2:16 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Can't remember for c3P0 but there should be some configuration like test-before-retrieve or something like that.

_________________
Emmanuel


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 8 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.