Permalink
Browse files

r3046@asus: jeremy | 2005-11-13 02:31:21 -0800

 AbstractAdapter#reconnect_if_inactive! returns boolean success.  AbstractAdapter#log alters exception message on reconnect failure rather than raising ConnectionFailed.


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3002 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 680e474 commit 4a5b042fc7805f95b4a096cafe0d57e105246095 @jeremy jeremy committed Nov 13, 2005
Showing with 8 additions and 4 deletions.
  1. +8 −4 activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -67,9 +67,12 @@ def log(sql, name)
nil
end
rescue Exception => e
- log_info("#{e.message}: #{sql}", name, 0)
- reconnect_if_inactive!
- raise ActiveRecord::StatementInvalid, "#{e.message}: #{sql}"
+ message = "#{e.class.name}: #{e.message}: #{sql}"
+ unless reconnect_if_inactive!
+ message = "(reconnect failed) #{message}"
+ end
+ log_info(message, name, 0)
+ raise ActiveRecord::StatementInvalid, message
end
def log_info(sql, name, runtime)
@@ -108,10 +111,11 @@ def reconnect_if_inactive!
if active?
@@reconnect_success += 1
@logger.info "#{adapter_name} automatically reconnected. Success rate: #{'%.2f' % self.class.reconnect_success_rate}%" if @logger
+ true
else
@@reconnect_failure += 1
@logger.warn "#{adapter_name} automatic reconnection failed. Success rate: #{'%.2f' % self.class.reconnect_success_rate}%" if @logger
- raise ActiveRecord::ConnectionFailed
+ false
end
else
@logger.warn "#{adapter_name} does not yet support automatic reconnection." if @logger

0 comments on commit 4a5b042

Please sign in to comment.