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
This commit is contained in:
parent
c6660e61b2
commit
a1912ccc89
4 changed files with 9 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue