class ActiveRecord::ConnectionAdapters::Transaction

def commit_records

def commit_records
  if records
    begin
      ite = unique_records
      if @run_commit_callbacks
        instances_to_run_callbacks_on = prepare_instances_to_run_callbacks_on(ite)
        run_action_on_records(ite, instances_to_run_callbacks_on) do |record, should_run_callbacks|
          record.committed!(should_run_callbacks: should_run_callbacks)
        end
      else
        while record = ite.shift
          # if not running callbacks, only adds the record to the parent transaction
          connection.add_transaction_record(record)
        end
      end
    ensure
      ite&.each { |i| i.committed!(should_run_callbacks: false) }
    end
  end
  if @run_commit_callbacks
    @callbacks&.each(&:after_commit)
  elsif @callbacks
    connection.current_transaction.append_callbacks(@callbacks)
  end
end