Class: ActiveRecord::Base
- Inherits:
-
Object
- Object
- ActiveRecord::Base
- Defined in:
- lib/patches.rb
Overview
see activerecord/lib/active_record/connection_adaptors/abstract/connection_specification.rb
Class Method Summary collapse
-
.clear_reloadable_connections! ⇒ Object
monkey patch to fix threading problems, see: dev.rubyonrails.org/ticket/7579.
- .spawn_reconnect(klass = self) ⇒ Object
Class Method Details
.clear_reloadable_connections! ⇒ Object
monkey patch to fix threading problems, see: dev.rubyonrails.org/ticket/7579
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/patches.rb', line 30 def self.clear_reloadable_connections! if @@allow_concurrency # Hash keyed by thread_id in @@active_connections. Hash of hashes. @@active_connections.each do |thread_id, conns| conns.each do |name, conn| if conn.requires_reloading? conn.disconnect! @@active_connections[thread_id].delete(name) end end end else # Just one level hash, no concurrency. @@active_connections.each do |name, conn| if conn.requires_reloading? conn.disconnect! @@active_connections.delete(name) end end end end |
.spawn_reconnect(klass = self) ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/patches.rb', line 6 def self.spawn_reconnect(klass=self) # keep ancestors' connection_handlers around to avoid them being garbage collected in the forked child @@ancestor_connection_handlers ||= [] @@ancestor_connection_handlers << self.connection_handler self.connection_handler = ActiveRecord::ConnectionAdapters::ConnectionHandler.new establish_connection end |