Skip to content
This repository
Browse code

Deprecate verification_timeout and verify before reset

Signed-off-by: Michael Koziarski <michael@koziarski.com>
  • Loading branch information...
commit 7ba28726150f5d4ee3b3cb676d6b73cc3b62e186 1 parent f54be2c
Nick Sieger authored September 04, 2008 NZKoz committed September 04, 2008
6  activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb
@@ -35,7 +35,6 @@ module ConnectionAdapters
35 35
     # * +wait_timeout+: number of seconds to block and wait for a connection
36 36
     #   before giving up and raising a timeout error (default 5 seconds).
37 37
     class ConnectionPool
38  
-      delegate :verification_timeout, :to => "::ActiveRecord::Base"
39 38
       attr_reader :spec
40 39
 
41 40
       def initialize(spec)
@@ -60,7 +59,6 @@ def initialize(spec)
60 59
       # held in a hash keyed by the thread id.
61 60
       def connection
62 61
         if conn = @reserved_connections[current_connection_id]
63  
-          conn.verify!(verification_timeout)
64 62
           conn
65 63
         else
66 64
           @reserved_connections[current_connection_id] = checkout
@@ -118,7 +116,7 @@ def clear_reloadable_connections!
118 116
       def verify_active_connections! #:nodoc:
119 117
         clear_stale_cached_connections!
120 118
         @connections.each do |connection|
121  
-          connection.verify!(verification_timeout)
  119
+          connection.verify!
122 120
         end
123 121
       end
124 122
 
@@ -200,8 +198,8 @@ def checkout_existing_connection
200 198
       end
201 199
 
202 200
       def checkout_and_verify(c)
  201
+        c.verify!
203 202
         c.run_callbacks :checkout
204  
-        c.verify!(verification_timeout)
205 203
         @checked_out << c
206 204
         c
207 205
       end
15  activerecord/lib/active_record/connection_adapters/abstract/connection_specification.rb
@@ -7,11 +7,6 @@ def initialize (config, adapter_method)
7 7
       end
8 8
     end
9 9
 
10  
-    # Check for activity after at least +verification_timeout+ seconds.
11  
-    # Defaults to 0 (always check.)
12  
-    cattr_accessor :verification_timeout, :instance_writer => false
13  
-    @@verification_timeout = 0
14  
-
15 10
     # The connection handler
16 11
     cattr_accessor :connection_handler, :instance_writer => false
17 12
     @@connection_handler = ConnectionAdapters::ConnectionHandler.new
@@ -101,6 +96,16 @@ def allow_concurrency=(flag)
101 96
         ActiveSupport::Deprecation.warn("ActiveRecord::Base.allow_concurrency= has been deprecated and no longer has any effect. Please remove all references to allow_concurrency=.")
102 97
       end
103 98
 
  99
+      # Deprecated and no longer has any effect.
  100
+      def verification_timeout
  101
+        ActiveSupport::Deprecation.warn("ActiveRecord::Base.verification_timeout has been deprecated and no longer has any effect. Please remove all references to verification_timeout.")
  102
+      end
  103
+
  104
+      # Deprecated and no longer has any effect.
  105
+      def verification_timeout=(flag)
  106
+        ActiveSupport::Deprecation.warn("ActiveRecord::Base.verification_timeout= has been deprecated and no longer has any effect. Please remove all references to verification_timeout=.")
  107
+      end
  108
+
104 109
       # Returns the connection currently associated with the class. This can
105 110
       # also be used to "borrow" the connection to do database work unrelated
106 111
       # to any of the specific Active Records.
12  activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
@@ -123,14 +123,10 @@ def requires_reloading?
123 123
         false
124 124
       end
125 125
 
126  
-      # Lazily verify this connection, calling <tt>active?</tt> only if it
127  
-      # hasn't been called for +timeout+ seconds.
128  
-      def verify!(timeout)
129  
-        now = Time.now.to_i
130  
-        if (now - @last_verification) > timeout
131  
-          reconnect! unless active?
132  
-          @last_verification = now
133  
-        end
  126
+      # Verify this connection by calling <tt>active?</tt> and reconnecting if
  127
+      # the connection is no longer active.
  128
+      def verify!(*ignored)
  129
+        reconnect! unless active?
134 130
       end
135 131
 
136 132
       # Provides access to the underlying database connection. Useful for
2  activerecord/test/cases/base_test.rb
@@ -880,7 +880,7 @@ def test_mass_assignment_protection
880 880
 
881 881
   def test_mass_assignment_protection_against_class_attribute_writers
882 882
     [:logger, :configurations, :primary_key_prefix_type, :table_name_prefix, :table_name_suffix, :pluralize_table_names, :colorize_logging,
883  
-      :default_timezone, :schema_format, :verification_timeout, :lock_optimistically, :record_timestamps].each do |method|
  883
+      :default_timezone, :schema_format, :lock_optimistically, :record_timestamps].each do |method|
884 884
       assert  Task.respond_to?(method)
885 885
       assert  Task.respond_to?("#{method}=")
886 886
       assert  Task.new.respond_to?(method)
2  activerecord/test/cases/connection_test_mysql.rb
@@ -24,7 +24,7 @@ def test_successful_reconnection_after_timeout_with_verify
24 24
     assert @connection.active?
25 25
     @connection.update('set @@wait_timeout=1')
26 26
     sleep 2
27  
-    @connection.verify!(0)
  27
+    @connection.verify!
28 28
     assert @connection.active?
29 29
   end
30 30
 end

0 notes on commit 7ba2872

Please sign in to comment.
Something went wrong with that request. Please try again.