>
>    - Write documentation for using ActiveRecord with PgBouncer (an 
>    explanation of the caveats, which features you can and can't use)
>
> Sounds like there definitely needs to be better documentation. Most of 
these issues come about with any connection pooler that supports connection 
pooling, so it doesn't need to be pgBouncer-specific.
 

> The last debatable point is client_min_messages. In Rails 4.0, WARNING 
> became the default setting 
> <https://github.com/rails/rails/commit/052e415f22b98bb45a5245ac8f7aa23c6f32e478>
>  
> to avoid noise in logs. I suspect the solution here is documentation - have 
> people set it to match the Postgres default in database.yml (or 
> conversely use PgBouncer's connect_query to match what ActiveRecord sets).
>

I don't know if this is possible, but the best way to handle this would be 
a mode where Rails simply disconnects from the database at the end of 
handling an inbound connection. One of the major points of a connection 
pooler is to make getting a new connection *fast*, so that you can connect 
and disconnect at will. You might not want that if you're not using an 
external pooler, but having rails doing pooling and then using an external 
pooler as well is just begging for trouble.

In 99% of cases letting the connection pooler worry about managing database 
connections will be the best option, because it makes each Rails thread 
stateless. The only time you wouldn't want that is if you need to run some 
very time consuming stuff before returning the page, and don't want to hold 
the database connection while you do it. The best way to handle that is to 
allow Rails code to close the database connection explicitly.

With current functionality, you can get all kinds of screwy behavior, 
beyond what's referenced here. For example, starting a transaction and not 
explicitly closing it (with either a commit or a rollback). This is the 
danger of any kind of nested connection pooling: if you're not extremely 
careful to keep both pools in sync you're going to get all kinds of weird 
things.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to