From: Chuck Remes Date: 2009-09-10T06:28:55+09:00 Subject: Re: EventMachine.defer and ActiveRecord connection pool? On Sep 9, 2009, at 4:14 PM, Artūras Šlajus wrote: > Chuck Remes wrote: >> I have a guess. I guess that your CONFIG['resources_manager.period'] >> is set to 0 or quite close to it. If so, the PeriodicTimer is >> probably >> firing on every "crank" of the EM reactor which is deferring more and >> more of your singleton blocks. There isn't any time left over to >> clean >> up connections to the ActiveRecord connection pool and you are >> running >> out. > Nop, it's 1 second for testing. It happens even if you set it to 1 > minute. Loads of time to clean up and still... > Hmm, that is curious. Then here's another guess... I haven't used rails in a long time, but I recall that AR required a call to verify_connections! or something crazy when running with threads. This is because each call opens its own connection to the database but there is (or was) no automatic close. So it could be that your threaded calls are opening up db connections and never closing them. You need to figure out how to close the connection or get AR to figure out that the others are stale or should be garbage collected. cr