I’ve setup my application to connect to multiple databases, but am
into a few issues in production. I also have a few questions.
First, I’m using rails 3-2-stable, because I was running in to a
statement bug, which is only fixed in this branch . I’m not up for
using master at this time, unless I absolutely need to.
Second, the pool size for the default and non-default database is 1,
is because I’m using unicorn. Also, because establish_connection on
multiple databases does not use the pool size .
I have 4 unicorn workers. After I start the app and rapidly refresh on
few pages, the default database sees 4 connections. The non-default
database sees only 1. And for the lifetime of the app, the non-default
database only sees one connection. I also think this is slowing down the
- What would cause the application to create only one connection for
non-default database, provided I have 4 workers? When I create a sample
app on my local machine that uses the same configs with different code,
actually get 4 connections for both. See my unicorn file here:
Unicorn Config · GitHub. All my non-default database models
inherit from something that looks like:
class OtherDb < ActiveRecord::Base
self.abstract_class = true
What’s the proper way to setup a unicorn.rb file for multiple
preload_app true, since I have establish_connection in the
model and need to establish_connection to the default in the after_fork?
Should I be looking into a different rack web server? My queries are
 Remove prepared statement from system query in postgresql adapter by evtuhovich · Pull Request #5872 · rails/rails · GitHub
 ActiveRecord::Base.establish_connection does not use the connection pool · Issue #7019 · rails/rails · GitHub