diff options
Diffstat (limited to 'spec/lib/gitlab/database/with_lock_retries_spec.rb')
-rw-r--r-- | spec/lib/gitlab/database/with_lock_retries_spec.rb | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/spec/lib/gitlab/database/with_lock_retries_spec.rb b/spec/lib/gitlab/database/with_lock_retries_spec.rb index 367f793b117..72074f06210 100644 --- a/spec/lib/gitlab/database/with_lock_retries_spec.rb +++ b/spec/lib/gitlab/database/with_lock_retries_spec.rb @@ -37,22 +37,19 @@ RSpec.describe Gitlab::Database::WithLockRetries do context 'when lock retry is enabled' do let(:lock_fiber) do Fiber.new do - configuration = ActiveRecordSecond.configurations.find_db_config(Rails.env).configuration_hash - - # Initiating a second DB connection for the lock - conn = ActiveRecordSecond.establish_connection(configuration).connection + # Initiating a separate DB connection for the lock + conn = ActiveRecord::Base.connection_pool.checkout conn.transaction do conn.execute("LOCK TABLE #{Project.table_name} in exclusive mode") Fiber.yield end - ActiveRecordSecond.remove_connection # force disconnect + # Releasing the connection we requested + ActiveRecord::Base.connection_pool.checkin(conn) end end before do - stub_const('ActiveRecordSecond', Class.new(ActiveRecord::Base)) - lock_fiber.resume # start the transaction and lock the table end |