restrict count timeout to 500 ms

This commit is contained in:
albert
2013-01-24 18:09:22 -05:00
parent e36e9dda1e
commit c6d4500c91

View File

@@ -601,9 +601,12 @@ class Post < ActiveRecord::Base
count = Danbooru.config.blank_tag_search_fast_count
else
begin
ActiveRecord::Base.connection.execute("SET statement_timeout = 500")
count = Post.tag_match(tags).undeleted.count
rescue ActiveRecord::StatementInvalid
count = Danbooru.config.blank_tag_search_fast_count || 1_000_000
ensure
ActiveRecord::Base.connection.execute("SET statement_timeout = 3000")
end
end