diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-13 10:32:17 +0000 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2005-11-13 10:32:17 +0000 |
commit | 4a5b042fc7805f95b4a096cafe0d57e105246095 (patch) | |
tree | fc043d66ff8a54a0c234e9fa81407ecf43ade289 /activerecord/lib/active_record | |
parent | 680e4742bec472b649d1260b764fcd0e3ad115b7 (diff) | |
download | rails-4a5b042fc7805f95b4a096cafe0d57e105246095.tar.gz rails-4a5b042fc7805f95b4a096cafe0d57e105246095.tar.bz2 rails-4a5b042fc7805f95b4a096cafe0d57e105246095.zip |
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
Diffstat (limited to 'activerecord/lib/active_record')
-rwxr-xr-x | activerecord/lib/active_record/connection_adapters/abstract_adapter.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 6b61c92de8..40ce6df618 100755 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -67,9 +67,12 @@ module ActiveRecord 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 @@ module ActiveRecord 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 |