maintenance: fix db timeouts in regenerate_post_counts!
Disable database timeouts durings daily maintenance. Fixes
`regenerate_post_counts!` timing out. Remove calls to without_timeout
because otherwise it will reenable the timeout when trying to restore
the old timeout (see 97cc873a3f).
This commit is contained in:
@@ -8,6 +8,7 @@ module DanbooruMaintenance
|
|||||||
end
|
end
|
||||||
|
|
||||||
def daily
|
def daily
|
||||||
|
ActiveRecord::Base.connection.execute("set statement_timeout = 0")
|
||||||
PostPruner.new.prune!
|
PostPruner.new.prune!
|
||||||
Upload.prune!
|
Upload.prune!
|
||||||
Delayed::Job.where('created_at < ?', 45.days.ago).delete_all
|
Delayed::Job.where('created_at < ?', 45.days.ago).delete_all
|
||||||
@@ -22,9 +23,7 @@ module DanbooruMaintenance
|
|||||||
TagChangeRequestPruner.reject_all
|
TagChangeRequestPruner.reject_all
|
||||||
Ban.prune!
|
Ban.prune!
|
||||||
|
|
||||||
ApplicationRecord.without_timeout do
|
|
||||||
ActiveRecord::Base.connection.execute("vacuum analyze") unless Rails.env.test?
|
ActiveRecord::Base.connection.execute("vacuum analyze") unless Rails.env.test?
|
||||||
end
|
|
||||||
rescue Exception => exception
|
rescue Exception => exception
|
||||||
rescue_exception(exception)
|
rescue_exception(exception)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
class PostPruner
|
class PostPruner
|
||||||
def prune!
|
def prune!
|
||||||
Post.without_timeout do
|
|
||||||
prune_pending!
|
prune_pending!
|
||||||
prune_flagged!
|
prune_flagged!
|
||||||
prune_mod_actions!
|
prune_mod_actions!
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ class SuperVoter < ApplicationRecord
|
|||||||
|
|
||||||
def self.init!
|
def self.init!
|
||||||
prune!
|
prune!
|
||||||
without_timeout do
|
|
||||||
report = PostVoteSimilarity.new(User.admins.first.id)
|
report = PostVoteSimilarity.new(User.admins.first.id)
|
||||||
|
|
||||||
report.calculate_positive(15).each do |element|
|
report.calculate_positive(15).each do |element|
|
||||||
@@ -22,7 +22,6 @@ class SuperVoter < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def update_user_on_create
|
def update_user_on_create
|
||||||
user.is_super_voter = true
|
user.is_super_voter = true
|
||||||
|
|||||||
@@ -184,10 +184,8 @@ class TagAlias < TagRelationship
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.update_cached_post_counts_for_all
|
def self.update_cached_post_counts_for_all
|
||||||
TagAlias.without_timeout do
|
|
||||||
execute_sql("UPDATE tag_aliases SET post_count = tags.post_count FROM tags WHERE tags.name = tag_aliases.consequent_name")
|
execute_sql("UPDATE tag_aliases SET post_count = tags.post_count FROM tags WHERE tags.name = tag_aliases.consequent_name")
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def create_mod_action
|
def create_mod_action
|
||||||
alias_desc = %Q("tag alias ##{id}":[#{Rails.application.routes.url_helpers.tag_alias_path(self)}]: [[#{antecedent_name}]] -> [[#{consequent_name}]])
|
alias_desc = %Q("tag alias ##{id}":[#{Rails.application.routes.url_helpers.tag_alias_path(self)}]: [[#{antecedent_name}]] -> [[#{consequent_name}]])
|
||||||
|
|||||||
Reference in New Issue
Block a user