"Max pool size" - connection error

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

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)