diff options
author | Nick Sieger <nick@nicksieger.com> | 2008-08-22 11:43:20 -0500 |
---|---|---|
committer | Nick Sieger <nick@nicksieger.com> | 2008-08-29 14:12:12 -0500 |
commit | a96b7d4c33757364a19ed1fc34f0a89801b8b2d7 (patch) | |
tree | caf325b1a09493e6ca4c150b762484020a5688ea /activerecord/lib/active_record/connection_adapters/abstract_adapter.rb | |
parent | d7d2d73d88e465cb0c618283862179accd8932e1 (diff) | |
download | rails-a96b7d4c33757364a19ed1fc34f0a89801b8b2d7.tar.gz rails-a96b7d4c33757364a19ed1fc34f0a89801b8b2d7.tar.bz2 rails-a96b7d4c33757364a19ed1fc34f0a89801b8b2d7.zip |
Add connection reset and verification upon each connection checkout
Diffstat (limited to 'activerecord/lib/active_record/connection_adapters/abstract_adapter.rb')
-rwxr-xr-x | activerecord/lib/active_record/connection_adapters/abstract_adapter.rb | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb index 4b78d9f2e9..c37ebf1410 100755 --- a/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_adapter.rb @@ -103,14 +103,23 @@ module ActiveRecord @active = false end + # Reset the state of this connection, directing the DBMS to clear + # transactions and other connection-related server-side state. Usually a + # database-dependent operation; the default method simply executes a + # ROLLBACK and swallows any exceptions which is probably not enough to + # ensure the connection is clean. + def reset! + execute "ROLLBACK" rescue nil + end + # Returns true if its safe to reload the connection between requests for development mode. # This is not the case for Ruby/MySQL and it's not necessary for any adapters except SQLite. def requires_reloading? false end - # Lazily verify this connection, calling <tt>active?</tt> only if it hasn't - # been called for +timeout+ seconds. + # Lazily verify this connection, calling <tt>active?</tt> only if it + # hasn't been called for +timeout+ seconds. def verify!(timeout) now = Time.now.to_i if (now - @last_verification) > timeout |