Commit 00c3783e authored by Adam Hegyi's avatar Adam Hegyi

Merge branch 'make-lock-retry-specs-compatible-with-ruby-3' into 'master'

Fix spec that introduces transaction timeout on Ruby 3.0.2

See merge request gitlab-org/gitlab!68150
parents af6f4c80 348a6648
......@@ -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
......
......@@ -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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment