method

unpin_connection!

rails latest stable - Class: ActiveRecord::ConnectionAdapters::ConnectionPool

Method not available on this version

This method is only available on newer versions. The first available version (v7.2.3) is shown here.

unpin_connection!()
public

No documentation available.

# File activerecord/lib/active_record/connection_adapters/abstract/connection_pool.rb, line 352
      def unpin_connection! # :nodoc:
        raise "There isn't a pinned connection #{object_id}" unless @pinned_connection

        clean = true
        @pinned_connection.lock.synchronize do
          @pinned_connections_depth -= 1
          connection = @pinned_connection
          @pinned_connection = nil if @pinned_connections_depth.zero?

          if connection.transaction_open?
            connection.rollback_transaction
          else
            # Something committed or rolled back the transaction
            clean = false
            connection.reset!
          end

          if @pinned_connection.nil?
            connection.pinned = false
            connection.steal!
            connection.lock_thread = nil
            checkin(connection)
          end
        end

        clean
      end