Commit f476e5ce authored by Krasimir Angelov's avatar Krasimir Angelov

Merge branch 'stomlinson/remove-partition-management-subtransactions' into 'master'

Remove subtransactions from partition management

See merge request gitlab-org/gitlab!70231
parents 62efc75a b07edea7
......@@ -74,8 +74,9 @@ module Gitlab
end
def create(partitions)
connection.transaction do
with_lock_retries do
# with_lock_retries starts a requires_new transaction most of the time, but not on the last iteration
with_lock_retries do
connection.transaction(requires_new: false) do # so we open a transaction here if not already in progress
partitions.each do |partition|
connection.execute partition.to_sql
......@@ -88,8 +89,9 @@ module Gitlab
end
def detach(partitions)
connection.transaction do
with_lock_retries do
# with_lock_retries starts a requires_new transaction most of the time, but not on the last iteration
with_lock_retries do
connection.transaction(requires_new: false) do # so we open a transaction here if not already in progress
partitions.each { |p| detach_one_partition(p) }
end
end
......
......@@ -18,6 +18,11 @@ RSpec.describe Gitlab::Database::Partitioning::PartitionManager do
it 'remembers registered models' do
expect { described_class.register(model) }.to change { described_class.models }.to include(model)
end
after do
# Do not leak the double to other specs
described_class.models.delete(model)
end
end
context 'creating partitions (mocked)' do
......
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