-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Pistos Christou wrote: > zdennis wrote: > >>Let me guess, your IRC game is multi-threaded? AR stores connections > > > I think you're onto something there... :) > > >>based on the Thread.current_thread.id (or at least it does in >>1.13.2, things changed slightly in 1.14.2). I ran into this problem as >>well. If you are using AR 1.13.2 I can give you a fix, >>otherwise you'll have to do it yourself or wait about a week for me to >>patch 1.14.2 (if it needs it). > > > I happen to be specifically require_gem'ing 1.13.2 for the game, solely > because stuff after 1.13.2 caused me even worse problems... > > >>Here is the code: >>How this helps, >> >>Zach > > > I put the code in place, and it seems to be helping, based on > preliminary testing. It's too early to tell for sure, though, so I will > keep you posted. Thanks for this patch. If it works, it will surely be > a great boon to the game. :) > Pistos, You can actually test this in a unit test. =) def test_connection_count 2.times do Thread.new{ Job.find_all } end assert_equal 1, ActiveRecord::Base.module_eval( "@@connection_cache" ).size, "Too many connections are being created!" end There is also a method on ActiveRecord::Base called 'active_connections' and it seems to always return 1, however if you actually do the module_eval for @@connection_cache, you will see there are more connections (that are potentially active) then 'active_connections' returns. There is another method on ActiveRecord::Base called 'threaded_connections' which returns true or false (by default true). I was hoping that if you set it to false, it would fix the problem, but setting it to false doesn't seem to do anything for this particular problem. I am gone for the weekend, if you find anything else out please post so I can read when I get back, otherwise I'll dive in over the weekend to AR and find out what I can (and to see if AR 1.14.2 has this problem) Have a good weekend Pistos! Zach -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.1 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFEf6oRMyx0fW1d8G0RAlMEAJ0Q3nfhiYUGfJsjjPbZQEgvqlcf4gCbB6Hv jsb6ZJpOF+cFnzBjJ0sC3z0= =V9ES -----END PGP SIGNATURE-----