Commit a1912ccc authored by Stan Hu's avatar Stan Hu

Delete container repository tags outside of transaction

When there are many tags in a container repository, deleting them
can exceed the default 60 second idle-in-transaction timeout in
Sidekiq. We now explicitly delete them in the DestroyService
before destroying the model.

Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/51380
parent c6660e61
......@@ -6,6 +6,8 @@ module Projects
def execute(container_repository)
return false unless can?(current_user, :update_container_image, project)
# Delete tags outside of the transaction to avoid hitting an idle-in-transaction timeout
container_repository.delete_tags!
container_repository.destroy
end
end
......
---
title: Delete container repository tags outside of transaction
merge_request: 21679
author:
type: fixed
......@@ -39,7 +39,7 @@ describe "Container Registry", :js do
visit_container_registry
expect_any_instance_of(ContainerRepository)
.to receive(:delete_tags!).and_return(true)
.to receive(:delete_tags!).twice.and_return(true)
click_on(class: 'js-remove-repo')
end
......
......@@ -33,6 +33,7 @@ describe Projects::ContainerRepository::DestroyService do
end
it 'deletes the repository' do
expect(repository).to receive(:delete_tags!).twice.and_call_original
expect { described_class.new(project, user).execute(repository) }.to change { ContainerRepository.all.count }.by(-1)
end
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