Mysql Timeout JRUBY / Tomcat


#1

Hello,
Trying to nail down the cause of this link issue, so far have not seen
any
network issues between app server and DB, but all of a sudden started
seeing
these. Is there any retry setting I could use ?

Jruby 1.1.4
Redhat Enterprise LInux
Java 1.6
/mysql-connector-java-5.1.6-bin.jar
Rails 2.1.1
Tomcat 5.5.26

ActiveRecord::ActiveRecordError: No operations allowed after connection
closed.Connection was implicitly closed due to underlying
exception/error:

** BEGIN NESTED EXCEPTION **

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException
MESSAGE: Communications link failure

Last packet sent to the server was 0 ms ago.

STACKTRACE:

com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications
link
failure

Last packet sent to the server was 0 ms ago.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
Method)
at
sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at
sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at
java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:406)
at
com.mysql.jdbc.SQLError.createCommunicationsException(SQLError.java:1074)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2985)
at com.mysql.jdbc.MysqlIO.reuseAndReadPacket(MysqlIO.java:2871)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3414)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1936)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2060)
at
com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2536)
at
com.mysql.jdbc.ConnectionImpl.setAutoCommit(ConnectionImpl.java:4874)
at
jdbc_adapter.JdbcAdapterInternalService.begin(JdbcAdapterInternalService.java:394)
at
jdbc_adapter.JdbcAdapterInternalService$s_method_0_0$RUBYINVOKER$begin.call(jdbc_adapter/JdbcAdapterInternalService$s_method_0_0$RUBYINVOKER$begin.gen)
at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:340)
at
ruby.jit.ruby.usr.local.apache_minus_tomcat_minus_5_dot_5_dot_26.webapps.insider_1_1.WEB_minus_INF.gems.gems.activerecord_minus_jdbc_minus_adapter_minus_0_dot_8_dot_2.lib.jdbc_adapter.jdbc_mysql.begin_db_transaction1516060359_840759659.rescue_1$RUBY$rescue(jdbc_mysql.rb:102)
at
ruby.jit.ruby.usr.local.apache_minus_tomcat_minus_5_dot_5_dot_26.webapps.insider_1_1.WEB_minus_INF.gems.gems.activerecord_minus_jdbc_minus_adapter_minus_0_dot_8_dot_2.lib.jdbc_adapter.jdbc_mysql.begin_db_transaction1516060359_840759659.file(jdbc_mysql.rb)
at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:202)
at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:340)


#2

I tried updating the wait_timeout variable to something really low but
still
seeing the issue only after periods of long inactivity.
Has anyone else hit this with MySQL 5 after a long period of inactivity
?
Is this a JDBC driver issue or strictly ActiveRecord?

Adam


#3

Hi AD,
Cause and work around is well documented here:
http://amitcodes.wordpress.com/2008/07/26/16/

AD wrote:

Rails 2.1.1
com.mysql.jdbc.exceptions.jdbc4.CommunicationsException
        at
        at
        at
org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:202)
        at
org.jruby.runtime.CallSite$InlineCachingCallSite.call(CallSite.java:340)


Regards

Gabe Wong
cloudAPPy
the Drag-and-drop Hosting CLOUD
http://www.cloudappy.com


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#4

can you safely use DBCP for a Jruby on Rails application ? I am still
getting these errors after running for a few days…

Thx
Adam


#5

Hi,

Were you ever able to get a resolution for this issue? We are
experiencing
a very similar issue (see below). I don’t think ours is related to the
mysql wait_timeout but instead think it’s related to a Firewall TCP
Connection Timeout. This pretty much hoses all the connections in the
pool
and they don’t recover, just keep rethrowing the same exception until
glassfish is restarted. I’m not sure why the connection is not
automatically reconnected and the query retried in this case.

Maybe a little monkey patching is needed for the ConnectionAdapters
execute
method?

[2906] [2906],b.size=>0,User Load (0.0ms)
ActiveRecord::ActiveRecordError:
No operations allowed after connection closed.Connection was implicitly
closed due to underlying exception/error:

** BEGIN NESTED EXCEPTION **

com.mysql.jdbc.CommunicationsException
MESSAGE: Communications link failure due to underlying exception:

** BEGIN NESTED EXCEPTION **

java.net.SocketException
MESSAGE: Connection reset

STACKTRACE:

java.net.SocketException: Connection reset
at
java.net.SocketOutputStream.socketWrite(SocketOutputStream.java:96)
at
java.net.SocketOutputStream.write(SocketOutputStream.java:136)
at
java.io.BufferedOutputStream.flushBuffer(BufferedOutputStream.java:65)
at
java.io.BufferedOutputStream.flush(BufferedOutputStream.java:123)
at com.mysql.jdbc.MysqlIO.send(MysqlIO.java:2637)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:1554)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:1665)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3170)
at com.mysql.jdbc.Connection.execSQL(Connection.java:3099)
at com.mysql.jdbc.Statement.executeQuery(Statement.java:1169)
at
jdbc_adapter.RubyJdbcConnection$6.call(RubyJdbcConnection.java:259)


View this message in context:
http://old.nabble.com/Mysql-Timeout-JRUBY---Tomcat-tp20354499p30088534.html
Sent from the JRuby - User mailing list archive at Nabble.com.