Merge branch '20183-update-priority-thread'
[arvados.git] / services / api / app / controllers / sys_controller.rb
index a67b124bd09ffc92834d3bd66a508ef96ffa6dc0..7d20cf77fdcd555de70d54fa931767337b7a586b 100644 (file)
@@ -12,9 +12,11 @@ class SysController < ApplicationController
       # Sweep trashed collections
       Collection.
         where('delete_at is not null and delete_at < statement_timestamp()').
+        in_batches(of: 15).
         destroy_all
       Collection.
         where('is_trashed = false and trash_at < statement_timestamp()').
+        in_batches(of: 15).
         update_all('is_trashed = true')
 
       # Sweep trashed projects and their contents (as well as role
@@ -50,7 +52,7 @@ class SysController < ApplicationController
     skipped_classes = ['Group', 'User']
     ActiveRecord::Base.descendants.reject(&:abstract_class?).each do |klass|
       if !skipped_classes.include?(klass.name) && klass.columns.collect(&:name).include?('owner_uuid')
-        klass.where({owner_uuid: p_uuid}).destroy_all
+        klass.where({owner_uuid: p_uuid}).in_batches(of: 15).destroy_all
       end
     end
     # Finally delete the project itself