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).
This commit is contained in:
evazion
2019-08-22 17:03:18 -05:00
parent fd639e3c81
commit 97cc873a3f

View File

@@ -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