Don't connect in Gitlab::Database.adapter_name
We don't need to connect when requesting the name of the database adapter. This in turn should prevent us from requesting/leaking connections just by asking whether we're using PostgreSQL or MySQL.
This commit is contained in:
parent
58131ac93c
commit
581cfbae24
3 changed files with 11 additions and 1 deletions
4
changelogs/unreleased/fix-ar-connection-leaks.yml
Normal file
4
changelogs/unreleased/fix-ar-connection-leaks.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: Don't connect in Gitlab::Database.adapter_name
|
||||
merge_request:
|
||||
author:
|
|
@ -6,7 +6,7 @@ module Gitlab
|
|||
MAX_INT_VALUE = 2147483647
|
||||
|
||||
def self.adapter_name
|
||||
connection.adapter_name
|
||||
ActiveRecord::Base.configurations[Rails.env]['adapter']
|
||||
end
|
||||
|
||||
def self.mysql?
|
||||
|
|
|
@ -5,6 +5,12 @@ class MigrationTest
|
|||
end
|
||||
|
||||
describe Gitlab::Database, lib: true do
|
||||
describe '.adapter_name' do
|
||||
it 'returns the name of the adapter' do
|
||||
expect(described_class.adapter_name).to be_an_instance_of(String)
|
||||
end
|
||||
end
|
||||
|
||||
# These are just simple smoke tests to check if the methods work (regardless
|
||||
# of what they may return).
|
||||
describe '.mysql?' do
|
||||
|
|
Loading…
Reference in a new issue