diff --git a/activerecord/lib/active_record/connection_adapters/abstract/connection_handler.rb b/activerecord/lib/active_record/connection_adapters/abstract/connection_handler.rb index 6a40dd6bcb7..9f04e8c931c 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/connection_handler.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/connection_handler.rb @@ -55,9 +55,6 @@ module ActiveRecord # about the model. The model needs to pass a connection specification name to the handler, # in order to look up the correct connection pool. class ConnectionHandler - FINALIZER = lambda { |_| ActiveSupport::ForkTracker.check! } - private_constant :FINALIZER - class StringConnectionName # :nodoc: attr_reader :name @@ -77,9 +74,6 @@ module ActiveRecord def initialize # These caches are keyed by pool_config.connection_name (PoolConfig#connection_name). @connection_name_to_pool_manager = Concurrent::Map.new(initial_capacity: 2) - - # Backup finalizer: if the forked child skipped Kernel#fork the early discard has not occurred - ObjectSpace.define_finalizer self, FINALIZER end def prevent_writes # :nodoc: diff --git a/activerecord/lib/active_record/connection_adapters/pool_config.rb b/activerecord/lib/active_record/connection_adapters/pool_config.rb index 6cd84478506..0010a48acd2 100644 --- a/activerecord/lib/active_record/connection_adapters/pool_config.rb +++ b/activerecord/lib/active_record/connection_adapters/pool_config.rb @@ -50,8 +50,6 @@ module ActiveRecord end def disconnect!(automatic_reconnect: false) - ActiveSupport::ForkTracker.check! - return unless @pool synchronize do @@ -65,8 +63,6 @@ module ActiveRecord end def pool - ActiveSupport::ForkTracker.check! - @pool || synchronize { @pool ||= ConnectionAdapters::ConnectionPool.new(self) } end diff --git a/activesupport/lib/active_support/fork_tracker.rb b/activesupport/lib/active_support/fork_tracker.rb index d029d02a95c..2ff8fc5bb75 100644 --- a/activesupport/lib/active_support/fork_tracker.rb +++ b/activesupport/lib/active_support/fork_tracker.rb @@ -24,14 +24,6 @@ module ActiveSupport end end - if Process.respond_to?(:_fork) # Ruby 3.1+ - def check! - # We trust the `_fork` callback - end - else - alias_method :check!, :after_fork_callback - end - def hook! ::Process.singleton_class.prepend(CoreExt) end diff --git a/activesupport/test/fork_tracker_test.rb b/activesupport/test/fork_tracker_test.rb index 02b116e8e7c..4738d1a7cdf 100644 --- a/activesupport/test/fork_tracker_test.rb +++ b/activesupport/test/fork_tracker_test.rb @@ -152,39 +152,6 @@ class ForkTrackerTest < ActiveSupport::TestCase ActiveSupport::ForkTracker.unregister(handler) end - def test_check - count = 0 - handler = ActiveSupport::ForkTracker.after_fork { count += 1 } - - assert_no_difference -> { count } do - 3.times { ActiveSupport::ForkTracker.check! } - end - - if Process.respond_to?(:_fork) - Process.stub(:pid, Process.pid + 1) do - assert_no_difference -> { count } do - 3.times { ActiveSupport::ForkTracker.check! } - end - - assert_no_difference -> { count } do - 3.times { ActiveSupport::ForkTracker.check! } - end - end - else - Process.stub(:pid, Process.pid + 1) do - assert_difference -> { count }, +1 do - 3.times { ActiveSupport::ForkTracker.check! } - end - end - - assert_difference -> { count }, +1 do - 3.times { ActiveSupport::ForkTracker.check! } - end - end - ensure - ActiveSupport::ForkTracker.unregister(handler) - end - def test_basic_object_with_kernel_fork read, write = IO.pipe called = false