Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6149951
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:32:28+00:00 2026-05-23T19:32:28+00:00

Somewhere in our Ruby code, there are three lines that (currently, for debugging purposes)

  • 0

Somewhere in our Ruby code, there are three lines that (currently, for debugging purposes) look like this:

puts "Established connection to: " \
    "#{ActiveRecord::Base.establish_connection(database_config).spec.config}"
puts "Connection is connected to: " \
    "#{ActiveRecord::Base.connection.instance_eval{@config.inspect}}
ActiveRecord::Base.connection.execute("SELECT 1") # Test connection

When this code is hit, the first line always prints

Established connection to: {:username=>"name", :host=>"localhost", :password=>"pass",
                            :adapter=>"mysql", :database=>"database1"}

informing us that the connection was established successfully. Usually, the second and third lines are executed as expected and everything goes its merry way. The second line then produces the same kind of result:

Connection is connected to: {:username=>"name", :host=>"localhost", :password=>"pass",
                            :adapter=>"mysql", :database=>"database1"}

However, for some reason, once in every while (for instance, twice during execution of a few hundred testcases), the second line produces:

Connection is connected to: {:username=>"name", :host=>"localhost", :password=>"pass",
                            :adapter=>"mysql", :database=>"database2"}

(note the different database) and the third line fails with

Mysql::Error: query: not connected: SELECT 1
$APP_ROOT/vendor/bundle/ruby/1.8/gems/activerecord-3.0.4/lib/active_record/connection_adapters/abstract_adapter.rb:207:in `log': Mysql::Error: query: not connected: SELECT 1 (ActiveRecord::StatementInvalid)
from $APP_ROOT/vendor/bundle/ruby/1.8/gems/activerecord-3.0.4/lib/active_record/connection_adapters/mysql_adapter.rb:289:in `execute'
from $APP_ROOT/somewhere_in_our_code.rb:84:in `establish_database_connection' (which is the third line quoted above)

(I think you can disregard the “StatementInvalid” in there: this is a valid MySQL query and the use of StatementInvalid in this message seems a minor bug in the ActiveRecord code)

So, for some reason, between establishing the connection and getting a connection to bind to the thread, ActiveRecord gets confused. Does anyone know why this could be happenening?

CentOS Linux, Ruby 1.8.7 (Enterprise Edition 2011.03), Rails 3.0.4, MySQL 2.8.1.

Almost all cases of this error you can find on the web concern downgrading the mysql DLL on Windows systems, which does not apply here.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:32:29+00:00Added an answer on May 23, 2026 at 7:32 pm

    The cause was an issue in the cucumber-rails gem, as filed here: https://github.com/cucumber/cucumber-rails/issues/152

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

From the answers to this question it appears there's a file somewhere on our
Is there a list somewhere on common Attributes which are used in objects like
I heard somewhere that you can drop down to C++ directly inside C# code.
I read somewhere that NTP is based on UDP and there's no security built
Somewhere along the line I picked up the notion that using iframes is 'bad
I read somewhere once that the modulus operator is inefficient on small embedded devices
I recently read somewhere that writing a regexp to match an email address, taking
I recall reading somewhere that using references to smart pointers can cause memory corruption.
I've read somewhere that functional programming is suitable to take advantage of multi-core trend
Related to this question , I'm instantiating a connection to our internal API inside

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.