Thread safety in activerecord(?), connection lost to mysql s

Hello all,

I know that this issue has come up before, but I read all the previous
posts
regarding thread safety and haven’t come up with a solution. I’m
spawning
lots of threads in a backgroundrb worker that each do things with
activerecord models. I get the connection lost to mysql server
exception
about 90% of the time, with my process working by sheer luck the other
10%.
I’ve broken down the problem to the following example that I just ran in
the
console:

Thread.abort_on_exception = true
=> true

100.times do
?> Thread.new do
?> Client.find(:first)

end
end
/usr/local/lib/ruby/gems/1.8/gems/activerecord-1.14.2/lib/active_record/connection_adapters/abstract_adapter.rb:120:in
`log’: Mysql::Error: Lost connection to MySQL server during query:
SELECT *
FROM clients LIMIT 1 (ActiveRecord::StatementInvalid)

I think that is a simple enough example to exemplify exactly what I am
trying to accomplish. Any help is seriously appreciated, as I’ve been
struggling with this issue off and on for countless hours.

Thank you in advance,
Zack H.