diff options
author | Eugen Rochko <eugen@zeonfederated.com> | 2022-04-29 22:43:07 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-29 22:43:07 +0200 |
commit | 7b0fe4aef97c6a5f73a03146b669a415f396799c (patch) | |
tree | 328a1117bf021f1ffc0e126e9563f71b31862f1e /lib/mastodon/search_cli.rb | |
parent | 6476f7e4da4da7c353d497aae5a86fc3909ce532 (diff) |
Fix opening and closing Redis connections instead of using a pool (#18171)
* Fix opening and closing Redis connections instead of using a pool * Fix Redis connections not being returned to the pool in CLI commands
Diffstat (limited to 'lib/mastodon/search_cli.rb')
-rw-r--r-- | lib/mastodon/search_cli.rb | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/mastodon/search_cli.rb b/lib/mastodon/search_cli.rb index 6ad9d7b6a..74f980ba1 100644 --- a/lib/mastodon/search_cli.rb +++ b/lib/mastodon/search_cli.rb @@ -59,9 +59,7 @@ module Mastodon index.specification.lock! end - db_config = ActiveRecord::Base.configurations[Rails.env].dup - db_config['pool'] = options[:concurrency] + 1 - ActiveRecord::Base.establish_connection(db_config) + reset_connection_pools! pool = Concurrent::FixedThreadPool.new(options[:concurrency]) added = Concurrent::AtomicFixnum.new(0) @@ -139,6 +137,9 @@ module Mastodon sleep 1 rescue => e progress.log pastel.red("Error importing #{index}: #{e}") + ensure + RedisConfiguration.pool.checkin if Thread.current[:redis] + Thread.current[:redis] = nil end end end |