开发者

Rails ActiveRecord w/ MySQL Hangs Once Connection Pool Limit is Reached

Unless specified, ActiveRecord fires up 4 default connections.

I've noticed if I reload a simple page, which makes at least one ActiveRecord call, 4 times every thing functions normal. However, on the fifth time, it hangs for almost 5 seconds. So, every 5th page load it hangs for 5 seconds.

I upped the default connection pool in my adapter to 8 and now it hangs every 9th page request. It seems like it doesn't reuse connections but instead kills them and regenerates them once the pool limit is reached.

I'm not actually using ActiveRecord with entire Rails stack.

Is there a magical ActiveRecord connection flag which prevents this from 开发者_JAVA百科happening? Or, is there something else going wrong?


Hot damn that was easy...

ActiveRecord::Base.clear_active_connections!

http://coderrr.wordpress.com/2009/01/12/rails-22-activerecord-connection-cleanup/

Sure wish this was something you could configure so you don't have to call it every time.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜