Thank you for taking an interest...

Mark Reginald James wrote:
> Fritz Anderson wrote:
>> 
>> I am sleeping for 5 minutes and retrying the find(). Is this enough?
>> 
>> Or should I re-run ActiveRecord::Base.establish_connection as well?
> 
> Is this in response to a normal controller request?

The application is not full Rails; it has no ActiveController instances.

> You might like to call Message.verify_active_connections!
> before your find.

An interesting proposition. verify_active_connections! has no rdoc 
available, and in fact abstract/connection_specification.rb marks it 
:nodoc:. Doesn't this suggest it isn't for typical use?

I don't exactly see what the method does when a connection is lost. Its 
last construct is a Hash#each_value, which doesn't suggest a useful 
return value. Does it raise an exception? Which? And what am I to do 
with it once I rescue it?

Also, while I'm on Rails 1.2.6, I see that the method is deprecated for 
2.2.1 (and still undocumented as of 2.1).


An update on my situation -- can anyone verify that this is a sensible 
approach? I propose to use this function as a wrapper on my find()s:

==
def catching_mysql_error
   retval = true
   begin
      yield
   rescue Mysql::Error => e
      # Catch the exception and try again in two minutes.
      # This also requires checking to mail the periodic report, or the 
condition will never be reported.
      log_to_report_file "#{Time.now} - ecod-poll - #{e}. Waiting 2 
minutes.\n#{e.backtrace}"
      check_email_task
      sleep 120

      # Disconnect and reconnect the DB connection.
      spec = ActiveRecord::Base.remove_connection
      ActiveRecord::Base.establish_connection spec

      retval = false
   end
   retval
end
==

Thanks for your help.

    — F

-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to