ruby on rails - ActiveRecord::ConnectionNotEstablished - No connection pool for X -


i can't make sinatra/ruby app hosted on heroku works desired. fiddled setup trying resolve issue far no results.

activerecord::connectionnotestablished - no connection pool user: 2015-06-25t14:26:11.736854+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_adapters/abstract/connection_pool.rb:566:in `retrieve_connection' 2015-06-25t14:26:11.736856+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_handling.rb:113:in `retrieve_connection' 2015-06-25t14:26:11.736858+00:00 app[web.1]:    /app/vendor/bundle/ruby/2.0.0/gems/activerecord-4.2.1/lib/active_record/connection_handling.rb:87:in `connection' 

user 1 of activerecords table , app fails because try query it.

i use sinatra puma backup. here procfile:

web: ruby app/my-server.rb -s puma 

i checking how many open connections there using:

select count(*) pg_stat_activity pid <> pg_backend_pid()  , usename = current_user;  

but says 0 every time.

i'm hosting app on free plan , dev plan of herokupostgres.

i noticed problem occurs when there 2 quick calls api @ short interval of time. there 1, not 5 connections available, because 1st call succeds , second 1 fails. in database.yml setup pool 5.

i'm on rails 4.2.1 , postgres 9.4

here database.yml aswell:

default: &default   adapter: postgresql   encoding: utf8   pool: 5   timeout: 5000  production:   <<: *default   host: my_db_address   port: 5432   database: my_db_name   username: my_db_user_name   password: my_db_password  < test , development ommited > 

do miss configuration or free heroku plan chokes on it?

please check how sinatra app established connection

configure :production, :development   db = uri.parse(env['database_url'] || 'postgres://localhost/mydb')   pool = env["db_pool"] || env['max_threads'] || 5   activerecord::base.establish_connection(         adapter:  db.scheme == 'postgres' ? 'postgresql' : db.scheme,         host:      db.host,         username:  db.user,         password:  db.password,         database:  db.path[1..-1],         encoding:  'utf8',         pool:      pool   ) end 

make sure have proper settings pool, make sure have heroku config db_pool or max_threads.

heroku config:set db_pool=5 

or

heroku config:set max_threads=5 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -