diff options
author | Robert Speicher <robert@gitlab.com> | 2018-05-29 20:47:47 +0300 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2018-05-29 20:47:47 +0300 |
commit | efcadd2d3c3eaa1e8d25275d8aef357a2ffb6fcb (patch) | |
tree | 2ef38d817a39be3bf53f973404dc84536a3fc6c8 /app/services/projects/destroy_service.rb | |
parent | 71b2eb7d935ab4f5ee3d901dad259d9fc02b1a22 (diff) | |
parent | 760fdd1dd31d30d5ab407a0c42e864040d79504c (diff) |
Merge branch 'sh-batch-dependent-destroys' into 'master'
Fix project destruction failing due to idle in transaction timeouts
Closes #44610
See merge request gitlab-org/gitlab-ce!18609
Diffstat (limited to 'app/services/projects/destroy_service.rb')
-rw-r--r-- | app/services/projects/destroy_service.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/services/projects/destroy_service.rb b/app/services/projects/destroy_service.rb index 077d27c5836..de0125ed0dd 100644 --- a/app/services/projects/destroy_service.rb +++ b/app/services/projects/destroy_service.rb @@ -137,7 +137,13 @@ module Projects trash_repositories! - project.team.truncate + # Rails attempts to load all related records into memory before + # destroying: https://github.com/rails/rails/issues/22510 + # This ensures we delete records in batches. + # + # Exclude container repositories because its before_destroy would be + # called multiple times, and it doesn't destroy any database records. + project.destroy_dependent_associations_in_batches(exclude: [:container_repositories]) project.destroy! end end |