# "Max pool size" - connection error

**URL:** <https://www.ruby-forum.com/t/max-pool-size-connection-error/160156>\
**Category:** Ferret\
**Created:** [February 12, 2009, 11:42am UTC](https://www.ruby-forum.com/t/max-pool-size-connection-error/160156 "2009-02-12T11:42:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [February 12, 2009, 11:42am UTC](https://www.ruby-forum.com/t/max-pool-size-connection-error/160156/1 "2009-02-12T11:42:16Z")

</div>

On our server, which is nginx with an 8-mongrel cluster, and a  
ferret\_server for searching, we get an intermittent error when doing  
ferret searches - always on the same index (for the User class). I  
don’t know why it’s always this same index - it’s smaller, with less  
indexed fields, then some of the other indexes, and is generally  
unremarkable.

When the error occurs, i get this in the log:

### 

/ebs/www/apps/e\_learning\_resource/releases/20090205174825/app/controllers/application.rb:97:in  
`rescue\_action’: #\<ActiveRecord::ConnectionTimeoutError: could not  
obtain a database connection within 5 seconds. The max pool size is  
currently 5; consider increasing it.\>

ActiveRecord::ConnectionTimeoutError (could not obtain a database  
connection within 5 seconds. The max pool size is currently 5; consider  
increasing it.):  
(druby://localhost:9010)  
/usr/local/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active\_record/connection\_adapters/abstract/connection\_pool.rb:198:in  
`checkout’

This seems to be random but my suspicion is that it’s to do with  
mongrel. If you keep doing the same search, you’re effectively randomly  
given a mongrel, which then accesses the ferret server to do the search.  
So maybe some of the mongrels can connect and some can’t? Now, our site  
isn’t very busy (it’s a subscriber-only site), so it’s unlikely that 6  
or more mongrels are trying to do a search at the same time - and  
looking in the log, before the crash, i can’t see any other searches  
going on.

With reference to the pool size, i’m not even sure which database it’s  
talking about - is that ferret’s own database, rather than our standard  
application database? It’s at this point that the gaps in my knowledge  
start to show…

anyway, grateful for any help/advice/insight…

thanks  
max

---

<div class="post-metadata">

**Author:** ![cmaxvv](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/85f322/32.png) [@cmaxvv](https://www.ruby-forum.com/u/cmaxvv)\
**Post date:** [February 13, 2009, 5:01pm UTC](https://www.ruby-forum.com/t/max-pool-size-connection-error/160156/2 "2009-02-13T17:01:08Z")

</div>

Just in case anyone was wondering, or more likely, in case anyone  
encounters this problem and happens to google to this post, then i fixed  
it (at least, it hasn’t broke yet) by adding this option to the end of  
my options in config/database.yml:

pool: 8

(8 because we have 8 mongrels running)
