I get ActiveRecord::ConnectionTimeoutError in a daemon that works regardless of the rails application. I am using Passenger with Apache and MySQL as a database.
The default pool size for passengers is 6 (at least what the documentation tells me), so it should not use more than 6 connections.
I set the ActiveRecord pool size to 10, although I thought that my daemon needed only one connection. My daemon is a single process with multiple threads, which calls ActiveRecord here and there to store material in a database that it shares with the application rails.
What I need to find out is that the threads simply cannot share one connection, or if they just continue to request new connections without letting go of their old connections. I know that I could just increase the size of the pool and postpone the problem, but the daemon can have hundreds of threads and sooner or later the pool will work out of connections.
The first thing I would like to know is that Passenger really only uses 6 connections and that the problem is the daemon. How to check it?
Secondly, I would like to find out if each thread needs its own connection or just need to repeat the use of an existing connection. If they need their own connections, maybe they just need to tell them not to hold onto them when they don't use them? Threads sleep most of all most of the time.
source share