From: "Artūras Šlajus" Date: 2009-09-10T06:14:01+09:00 Subject: Re: EventMachine.defer and ActiveRecord connection pool? 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... > BTW, EM#defer uses a threadpool (size of 20). It enqueues each #defer > request to a Queue (thread safe). As each thread in the pool completes > its task it pops the next one off the queue. > > If you flood the queue (which I suspect) then the newest tasks are > going to starve while waiting for the previous ones to complete. As > each task completes, try outputting the number of tasks in your > @@running hash and see if it is a large number. The whole purpose of @@running hash is to ensure that same task won't be running in parallel. I don't need two resource managers messing up values with database, so it skips that block completely if same task is still running. -- Posted via http://www.ruby-forum.com/.