debian-mirror-gitlab/lib/gitlab/database/migrations/pg_backend_pid.rb
2023-06-20 00:43:36 +05:30

38 lines
1 KiB
Ruby

# frozen_string_literal: true
module Gitlab
module Database
module Migrations
module PgBackendPid
module MigratorPgBackendPid
extend ::Gitlab::Utils::Override
override :with_advisory_lock_connection
def with_advisory_lock_connection
super do |conn|
Gitlab::Database::Migrations::PgBackendPid.say(conn)
yield(conn)
Gitlab::Database::Migrations::PgBackendPid.say(conn)
end
end
end
def self.patch!
ActiveRecord::Migrator.prepend(MigratorPgBackendPid)
end
def self.say(conn)
pg_backend_pid = conn.select_value('SELECT pg_backend_pid()')
db_name = Gitlab::Database.db_config_name(conn)
# rubocop:disable Rails/Output
puts "#{db_name}: == [advisory_lock_connection] " \
"object_id: #{conn.object_id}, pg_backend_pid: #{pg_backend_pid}"
# rubocop:enable Rails/Output
end
end
end
end
end