Method: ActiveRecord::ConnectionAdapters::AbstractAdapter#expire

Defined in:
activerecord/lib/active_record/connection_adapters/abstract_adapter.rb

#expireObject

this method must only be called while holding connection pool’s mutex



303
304
305
306
307
308
309
310
311
312
313
314
315
316
# File 'activerecord/lib/active_record/connection_adapters/abstract_adapter.rb', line 303

def expire
  if in_use?
    if @owner != ActiveSupport::IsolatedExecutionState.context
      raise ActiveRecordError, "Cannot expire connection, " \
        "it is owned by a different thread: #{@owner}. " \
        "Current thread: #{ActiveSupport::IsolatedExecutionState.context}."
    end

    @idle_since = Process.clock_gettime(Process::CLOCK_MONOTONIC)
    @owner = nil
  else
    raise ActiveRecordError, "Cannot expire connection, it is not currently leased."
  end
end