Lost connection to MySQL server during query


#1

Hi,

I’m trying to run an existing rails app on jruby. When I run:

jruby -S rake db:test:clone

I get the following stacktrace. Right now we’re using rails 1.2.3, but
I tried this with rails 1.2.6 and 2.0.2:

rake aborted!
Mysql::Error: Lost connection to MySQL server during query: SHOW TABLES
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/connection_adapters/abstract_adapter.rb:128:in log' /usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/connection_adapters/mysql_adapter.rb:243:inexecute’
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/connection_adapters/mysql_adapter.rb:326:in tables' /usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/schema_dumper.rb:54:intables’
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/
active_record/schema_dumper.rb:23:in dump' /usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/ active_record/schema_dumper.rb:17:indump’
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/tasks/
databases.rake:24
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/tasks/
databases.rake:23:in open' /usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/tasks/ databases.rake:23 /usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb: 617:incall’
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:
617:in execute' /usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb: 612:ineach’
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:
612:in execute' /usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb: 578:ininvoke_with_call_chain’
/usr/local/jruby/lib/ruby/1.8/monitor.rb:191:in mon_synchronize' /usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb: 571:ininvoke_with_call_chain’
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:
588:in invoke_prerequisites' /usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb: 585:ineach’
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:
585:in invoke_prerequisites' /usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb: 577:ininvoke_with_call_chain’
/usr/local/jruby/lib/ruby/1.8/monitor.rb:191:in mon_synchronize' /usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb: 571:ininvoke_with_call_chain’
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:
564:in invoke' /usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb: 2027:ininvoke_task’
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:
2005:in top_level' /usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb: 2005:ineach’
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:
2005:in top_level' /usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb: 2044:instandard_exception_handling’
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:
1999:in top_level' /usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb: 1977:inrun’
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:
2044:in standard_exception_handling' /usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb: 1974:inrun’
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/bin/rake:31
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/bin/rake:
19:in `load’
/usr/local/jruby/bin/rake:19

Here are the gems I have installed:

actionmailer (2.3.2, 2.0.2, 1.3.6, 1.3.3)
actionpack (2.3.2, 2.0.2, 1.13.6, 1.13.3)
actionwebservice (1.2.6, 1.2.3)
activerecord (2.3.2, 2.0.2, 2.0.1, 1.15.6, 1.15.3)
ActiveRecord-JDBC (0.5)
activerecord-jdbc-adapter (0.9.1)
activerecord-jdbcmysql-adapter (0.9.1)
activeresource (2.3.2, 2.0.2)
activesupport (2.3.2, 2.0.2, 2.0.1, 1.4.4, 1.4.2)
archive-tar-minitar (0.5.2)
color (1.4.0)
fastercsv (1.2.3)
gem_plugin (0.2.3)
hoe (1.12.1)
hpricot (0.6.164)
htmltools (1.10)
jdbc-mysql (5.0.4)
jruby-openssl (0.4)
macaddr (1.0.0)
mocha (0.9.5)
mongrel (1.1.5)
pdf-writer (1.1.8)
rails (2.3.2, 2.0.2, 1.2.6, 1.2.3)
rake (0.8.4)
rspec (1.2.0)
rubyforge (1.0.3)
rubyful_soup (1.0.4)
ruport (1.6.1)
sources (0.0.1)
transaction-simple (1.4.0)
uuid (2.0.1)

Any help?

Thanks
Brendan


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#2

Hi,

Sorry I forgot to mention. I am running OSX and have added:

if RUBY_PLATFORM =~ /java/
require ‘rubygems’
gem ‘activerecord-jdbc-adapter’
require ‘jdbc_adapter’
end

to environment.rb as explained in:

http://github.com/nicksieger/activerecord-jdbc-adapter/tree/master

Thanks again

On Apr 14, 2009, at 11:46 AM, Brendan Grainger wrote:

Mysql::Error: Lost connection to MySQL server during query: SHOW
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/activerecord-1.15.3/
617:in call' 571:ininvoke_with_call_chain’
571:in `invoke_with_call_chain’
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/bin/rake:
ActiveRecord-JDBC (0.5)
htmltools (1.10)
rubyful_soup (1.0.4)
ruport (1.6.1)
sources (0.0.1)
transaction-simple (1.4.0)
uuid (2.0.1)

Any help?

Thanks
Brendan


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#3

Don’t suppose anyone has had a similar experience with OSX?

Thanks

On Apr 14, 2009, at 12:30 PM, Brendan Grainger wrote:

to environment.rb as explained in:

log' /usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/activerecord-1.15.3/ rake.rb:617:inexecute’
rake.rb:588:in invoke_prerequisites' rake.rb:564:ininvoke’
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/
/usr/local/jruby/bin/rake:19
activerecord-jdbcmysql-adapter (0.9.1)
jruby-openssl (0.4)
sources (0.0.1)
transaction-simple (1.4.0)
uuid (2.0.1)

Any help?

Thanks
Brendan


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#4

This happens always, when I run:

jrake db:migrate

Usually when trying to create an index.

Thanks!

On Apr 15, 2009, at 1:59 PM, AD wrote:

Don’t suppose anyone has had a similar experience with OSX?

require ‘rubygems’
On Apr 14, 2009, at 11:46 AM, Brendan Grainger wrote:

execute' lib/active_record/schema_dumper.rb:23:in tasks/databases.rake:23:in rake.rb:617:in /usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/invoke_prerequisites’
rake.rb:577:in

`each’
rake.rb:1999:in
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/
Here are the gems I have installed:
archive-tar-minitar (0.5.2)
mongrel (1.1.5)


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#5

can you connect to mysql from the server outside of Jruby ? Can you
confirm the credentials are correct in database.yml ?

Are you using activerecord-jdbc ?

On Wed, Apr 15, 2009 at 2:08 PM, Brendan Grainger
removed_email_address@domain.invalid wrote:

does this happen for every query or just intermittently?

Don’t suppose anyone has had a similar experience with OSX?

require ‘rubygems’
On Apr 14, 2009, at 11:46 AM, Brendan Grainger wrote:

dump'open’
`execute’
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:578:in

`invoke_with_call_chain’

`top_level’
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1974:in
actionpack (2.3.2, 2.0.2, 1.13.6, 1.13.3)
gem_plugin (0.2.3)
rake (0.8.4)


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#6

does this happen for every query or just intermittently?

We had some issues with connections being lost so we had to implement
DBCP in Tomcat to handle proper connection pooling in case a
connection died.

Adam

On Wed, Apr 15, 2009 at 12:19 PM, Brendan Grainger
removed_email_address@domain.invalid wrote:

if RUBY_PLATFORM =~ /java/

tables' /usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rails-1.2.3/lib/tasks/databases.rake:24execute’

`invoke_prerequisites’

`top_level’
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2044:in
Here are the gems I have installed:
archive-tar-minitar (0.5.2)
mongrel (1.1.5)

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#7

Answers below:

On Apr 15, 2009, at 2:55 PM, AD wrote:

can you connect to mysql from the server outside of Jruby ?
Yes. In fact I can run the application no problem using the same
configuration. It seems only to lose the connection when doing ddl
type things like: jrake db:migrate, jrake db:test:clone or running
tests (jrake test).

Can you confirm the credentials are correct in database.yml ?
Yes. They work fine if I start up using MRI.

Are you using activerecord-jdbc ?
Yes. Here is the relevant output of jgem list :

activerecord-jdbc-adapter (0.9.1)
activerecord-jdbcmysql-adapter (0.9.1)

I have the following in my environment.rb

Only needed for rails 1.2.x

if RUBY_PLATFORM =~ /java/
puts
"\n
"
puts " Running jdbc adapter "
puts
"
\n
"
require ‘rubygems’
gem ‘activerecord-jdbc-adapter’
require ‘jdbc_adapter’
end

Thanks again
Brendan

Thanks!

Adam

Hi,

jruby -S rake db:test:clone

tasks/databases.rake:23

/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/
rake.rb:2027:in
`each’

/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/bin/
activerecord (2.3.2, 2.0.2, 2.0.1, 1.15.6, 1.15.3)
hpricot (0.6.164)
rubyforge (1.0.3)
Brendan


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#8

Here it is. Note that running under MRI everything works fine.

defaults: &defaults
username: blog
password: blog
host: localhost
adapter: mysql
socket: /var/run/mysqld/mysql.sock # I know this is weird, it’s not
my fault

When we use rails > 2.0 adapter: jdbcmysql

development:
database: blog_development
<<: *defaults

test:
database: blog_test
<<: *defaults


I know rake db:migrate tries to read the development section by default.

Thanks

On Apr 15, 2009, at 5:31 PM, AD wrote:

On Apr 15, 2009, at 2:55 PM, AD wrote:

Can you confirm the credentials are correct in database.yml ?
I have the following in my environment.rb
require ‘rubygems’
removed_email_address@domain.invalid wrote:

removed_email_address@domain.invalid wrote:

Thanks again

1.2.3,

`execute’
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/

/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/

rake.rb:571:in
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/

`standard_exception_handling’
rake:19:in
ActiveRecord-JDBC (0.5)
htmltools (1.10)
rubyful_soup (1.0.4)


http://xircles.codehaus.org/manage_email

To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#9

can you show me a copy of your database.yml ?

rake db:migrate by default tries to read the “development” section.
Make sure you either tell db:migrate to use prod or update your
development section of database.yml.

On Wed, Apr 15, 2009 at 3:57 PM, Brendan Grainger
removed_email_address@domain.invalid wrote:

gem ‘activerecord-jdbc-adapter’

does this happen for every query or just intermittently?

Don’t suppose anyone has had a similar experience with OSX?

require ‘rubygems’
On Apr 14, 2009, at 11:46 AM, Brendan Grainger wrote:

tried this with rails 1.2.6 and 2.0.2:

/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/schema_dumper.rb:17:in

/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:612:in
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in
each' /usr/local/jruby/lib/ruby/1.8/monitor.rb:191:inmon_synchronize’

/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:1977:in
`run’
actionpack (2.3.2, 2.0.2, 1.13.6, 1.13.3)
gem_plugin (0.2.3)
rake (0.8.4)


http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#10

Hi,

Thanks, but if you look at my first post that’s exactly what I did.

Anyway, I seem to have figured it out (cross fingers). I made the
following changes to my.cnf:

InnoDB Settings

innodb_buffer_pool_size = 128M
innodb_additional_mem_pool_size = 20M

and bingo! No more lost connections. I tried these settings with both
the disk image from mysql.com (version 5.1.33) and the macports
version (version 5.0.75) . Both were failing to db:migrate previously
on Leopard. Both seem to work now.

Thanks all
Brendan

On Apr 15, 2009, at 8:43 PM, AD wrote:

adapter: mysql
test:
On Apr 15, 2009, at 5:31 PM, AD wrote:

Answers below:
test).
activerecord-jdbcmysql-adapter (0.9.1)
puts

to environment.rb as explained in:

SHOW

/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/

/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/

/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/

lib/rake.rb:578:in

/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/

/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/

lib/rake.rb:2044:in

`standard_exception_handling’

actionpack (2.3.2, 2.0.2, 1.13.6, 1.13.3)
gem_plugin (0.2.3)
rake (0.8.4)


http://xircles.codehaus.org/manage_email

To unsubscribe from this list, please visit:


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

#11

can you run it with --trace do see if you get any additional info ?

On Wed, Apr 15, 2009 at 5:43 PM, Brendan Grainger
removed_email_address@domain.invalid wrote:

development section of database.yml.

Yes. In fact I can run the application no problem using the same

Thanks again

connection died.

On Apr 14, 2009, at 12:30 PM, Brendan Grainger wrote:

I’m trying to run an existing rails app on jruby. When I run:
TABLES
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/activerecord-1.15.3/lib/active_record/connection_adapters/mysql_adapter.rb:243:in

/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:571:in

`invoke_task’
/usr/local/jruby-1.2.0/lib/ruby/gems/1.8/gems/rake-0.8.4/lib/rake.rb:2005:in

/usr/local/jruby/bin/rake:19
activerecord-jdbcmysql-adapter (0.9.1)
jruby-openssl (0.4)
sources (0.0.1)


http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email