Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConnectionPool#with_connection fails to check connections back in #14470

Closed
chris-maginatics opened this issue Mar 24, 2014 · 6 comments
Closed

Comments

@chris-maginatics
Copy link

It's easy to repro:

irb(main):005:0> 20.times.map { Thread.new { Foo.connection_pool.with_connection { Foo.count } }.value }
ActiveRecord::ConnectionTimeoutError: could not obtain a database connection within 5.000 seconds (waited 5.000 seconds)
@chris-maginatics chris-maginatics changed the title with_connection fails to check connections back in ConnectionPool#with_connection fails to check connections back in Mar 24, 2014
@rafaelfranca
Copy link
Member

cc @matthewd @tenderlove

@chris-maginatics
Copy link
Author

This may be a conflict with db_charmer. Investigating.

@matthewd
Copy link
Member

@chris-maginatics any news?

@robin850
Copy link
Member

(May be related with #12867 ; it looks like people are still experiencing such issue. However, this stacktrace does not include occurrences of db_charmer)

@chris-maginatics
Copy link
Author

@matthewd We can repro with this Dockerfile:

FROM ubuntu:12.04
RUN apt-get update \
 && apt-get -y install ruby1.9.1 ruby1.9.1-dev libsqlite3-dev libmysqlclient-dev make g++ git-core \
 && gem install --no-rdoc --no-ri rails -v 4.0.3 \
 && gem install --no-rdoc --no-ri therubyracer \
 && rails new foo

WORKDIR /foo
RUN echo "source 'http://rubygems.org'" > Gemfile \
 && echo "gem 'rails', '4.0.3'" >>Gemfile \
 && echo "gem 'sqlite3'" >>Gemfile \
 && echo "gem 'therubyracer'" >>Gemfile \
 && rails generate model bar \
 && rake db:migrate

# This one succeeds
RUN bundle --quiet \
 && echo '20.times.map { Thread.new { Bar.connection_pool.with_connection { Bar.count } }.value }' | bundle exec rails c

# This one fails
RUN echo "gem 'db-charmer', :git => 'https://github.com/kovyrin/db-charmer.git', :ref => '886898af'" >>Gemfile \
 && bundle --quiet \
 && echo '20.times.map { Thread.new { Bar.connection_pool.with_connection { Bar.count } }.value }' | bundle exec rails c

So it's definitely an interaction with db-charmer. We haven't dug farther into it yet since we have a workaround (use ActiveRecord::Base.connection_pool.with_connection instead of Bar.connection_pool.with_connection).

@matthewd
Copy link
Member

matthewd commented Apr 1, 2014

Okay, thanks. I'll declare this a db_charmer issue and close for now; please do yell if you find evidence to the contrary.

@matthewd matthewd closed this as completed Apr 1, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants