aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXavier Noria <fxn@hashref.com>2013-09-24 10:55:13 -0700
committerXavier Noria <fxn@hashref.com>2013-09-24 10:55:13 -0700
commitb1178aef3b44bd9e0153d2c4f8a2a2a590949999 (patch)
tree21d9f0c531174397c0173d51b7a81834c372ba06
parent3cdeac8cb7e8ab2c11d3a512675a7cd825fbb83e (diff)
parent73b6095e13ef6be47fcabd65fcdd9c814bb9b375 (diff)
downloadrails-b1178aef3b44bd9e0153d2c4f8a2a2a590949999.tar.gz
rails-b1178aef3b44bd9e0153d2c4f8a2a2a590949999.tar.bz2
rails-b1178aef3b44bd9e0153d2c4f8a2a2a590949999.zip
Merge pull request #10822 from gaurish/pool
Add note about database connection pool in postgres template
-rw-r--r--guides/source/configuring.md11
-rw-r--r--railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml2
2 files changed, 13 insertions, 0 deletions
diff --git a/guides/source/configuring.md b/guides/source/configuring.md
index 5f170474ee..c499cd0727 100644
--- a/guides/source/configuring.md
+++ b/guides/source/configuring.md
@@ -759,4 +759,15 @@ Since the connection pooling is handled inside of Active Record by default, all
Any one request will check out a connection the first time it requires access to the database, after which it will check the connection back in, at the end of the request, meaning that the additional connection slot will be available again for the next request in the queue.
+If you try to use more connections than are available, Active Record will block
+and wait for a connection from the pool. When it cannot get connection, a timeout
+error similar to given below will be thrown.
+
+```ruby
+ActiveRecord::ConnectionTimeoutError - could not obtain a database connection within 5 seconds. The max pool size is currently 5; consider increasing it:
+```
+
+If you get the above error, you might want to increase the size of connection
+pool by incrementing the `pool` option in `database.yml`
+
NOTE. If you have enabled `Rails.threadsafe!` mode then there could be a chance that several threads may be accessing multiple connections simultaneously. So depending on your current request load, you could very well have multiple threads contending for a limited amount of connections.
diff --git a/railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml b/railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml
index eb569b7dab..0194dce6f3 100644
--- a/railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml
+++ b/railties/lib/rails/generators/rails/app/templates/config/databases/postgresql.yml
@@ -55,6 +55,8 @@ production:
adapter: postgresql
encoding: unicode
database: <%= app_name %>_production
+ # For details on connection pooling, see rails configration guide
+ # http://guides.rubyonrails.org/configuring.html#database-pooling
pool: 5
username: <%= app_name %>
password: