From 97cc873a3f46a5fc0850273209f79da97473a4e6 Mon Sep 17 00:00:00 2001 From: evazion Date: Thu, 22 Aug 2019 17:03:18 -0500 Subject: [PATCH] maintenenace: fix db timeouts during vacuuming. Setting the statement timeout at the beginning didn't work because `PostPruner.new.prune!` clobbers the timeout (it calls `without_timeout`, which doesn't restore the timeout properly if the timeout was zero). --- app/logical/danbooru_maintenance.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/logical/danbooru_maintenance.rb b/app/logical/danbooru_maintenance.rb index ed29be84b..1cb5cb388 100644 --- a/app/logical/danbooru_maintenance.rb +++ b/app/logical/danbooru_maintenance.rb @@ -8,7 +8,6 @@ module DanbooruMaintenance end def daily - ActiveRecord::Base.connection.execute("set statement_timeout = 0") PostPruner.new.prune! Upload.where('created_at < ?', 1.day.ago).delete_all Delayed::Job.where('created_at < ?', 45.days.ago).delete_all @@ -25,7 +24,10 @@ module DanbooruMaintenance TagChangeRequestPruner.warn_all TagChangeRequestPruner.reject_all Ban.prune! - ActiveRecord::Base.connection.execute("vacuum analyze") unless Rails.env.test? + + ApplicationRecord.without_timeout do + ActiveRecord::Base.connection.execute("vacuum analyze") unless Rails.env.test? + end rescue Exception => exception rescue_exception(exception) end