saved searches: fix failure when search returns no results.

* Don't try to call `sadd` when a search returns no results (`sadd`
  fails in this case).
* Add a timeout when populating the search.
* Don't offload the search to read replica. The main db is fine.
* Disable synchronous population of searches. This was too slow.
This commit is contained in:
evazion
2019-09-02 20:42:01 -05:00
parent 4abffc7faa
commit 2841f0742c
3 changed files with 28 additions and 11 deletions

View File

@@ -266,7 +266,7 @@ class ApplicationRecord < ActiveRecord::Base
connection.execute("SET STATEMENT_TIMEOUT = #{n}") unless Rails.env == "test"
yield
rescue ::ActiveRecord::StatementInvalid => x
DanbooruLogger.log(x, expected: true)
DanbooruLogger.log(x, expected: false, **new_relic_params)
return default_value
ensure
connection.execute("SET STATEMENT_TIMEOUT = #{CurrentUser.user.try(:statement_timeout) || 3_000}") unless Rails.env == "test"