Module: PgbConnectionReaperRb::PostgreSQLAdapterExtension
- Defined in:
- lib/pgb_connection_reaper_rb/postgresql_adapter_extension.rb
Instance Method Summary collapse
Instance Method Details
#reconnect!(**args) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/pgb_connection_reaper_rb/postgresql_adapter_extension.rb', line 5 def reconnect!(**args) # Rails 7.1+ handles locking and disconnect/connect cycle internally if ActiveRecord.version >= Gem::Version.new("7.1.0") super else # Rails 6.x and earlier: ensure thread-safe reconnection with manual lock lock = defined?(@lock) ? @lock : ActiveRecord::Base.connection_pool.instance_variable_get(:@mon_data) lock.synchronize do super disconnect! connect end end end |