diff options
Diffstat (limited to 'spec/lib/gitlab/database/with_lock_retries_outside_transaction_spec.rb')
-rw-r--r-- | spec/lib/gitlab/database/with_lock_retries_outside_transaction_spec.rb | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/spec/lib/gitlab/database/with_lock_retries_outside_transaction_spec.rb b/spec/lib/gitlab/database/with_lock_retries_outside_transaction_spec.rb index ff8e76311ae..0282a7af0df 100644 --- a/spec/lib/gitlab/database/with_lock_retries_outside_transaction_spec.rb +++ b/spec/lib/gitlab/database/with_lock_retries_outside_transaction_spec.rb @@ -37,22 +37,20 @@ RSpec.describe Gitlab::Database::WithLockRetriesOutsideTransaction 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 separate DB connection for the lock + conn = ActiveRecord::Base.connection_pool.checkout - # Initiating a second DB connection for the lock - conn = ActiveRecordSecond.establish_connection(configuration).connection 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 |