Sudden inexplicable active record connection timeouts while testing with RSPEC
It seems this is related to touching active record inside a spawned thread. It looks like the db connection doesn't get returned to the pool until it is reaped. I've been able to resolve this issue by explicitly asking for a connection ahead of time and closing it after I'm done. Try this:
Thread.new do ActiveRecord::Base.connection_pool.with_connection do |conn| UserMailer.accepted_parent_invitation_email(@parent_profile).deliver endend