class HotCompatibilityTest
Public Class Methods
name()
click to toggle source
# File activerecord/test/cases/hot_compatibility_test.rb, line 17 def self.name; "HotCompatibility"; end
Private Instance Methods
get_prepared_statement_cache(connection)
click to toggle source
# File activerecord/test/cases/hot_compatibility_test.rb, line 119 def get_prepared_statement_cache(connection) connection.instance_variable_get(:@statements) .instance_variable_get(:@cache)[Process.pid] end
with_two_connections() { |original_connection, ddl_connection| ... }
click to toggle source
Quails
will automatically clear the prepared statements on the connection that runs the migration, so we use two connections to simulate what would actually happen on a production system; we'd have one connection running the migration from the rake task (“ddl_connection” here), and we'd have another connection in a web worker.
# File activerecord/test/cases/hot_compatibility_test.rb, line 129 def with_two_connections run_without_connection do |original_connection| ActiveRecord::Base.establish_connection(original_connection.merge(pool_size: 2)) begin ddl_connection = ActiveRecord::Base.connection_pool.checkout begin yield original_connection, ddl_connection ensure ActiveRecord::Base.connection_pool.checkin ddl_connection end ensure ActiveRecord::Base.clear_all_connections! end end end