Skip to content

Commit

Permalink
Fix crash in tootctl commands making use of parallelization when El…
Browse files Browse the repository at this point in the history
…asticsearch is enabled (mastodon#24182)
  • Loading branch information
ClearlyClaire committed Mar 27, 2023
1 parent ab85f59 commit b97e63d
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/mastodon/cli_helper.rb
Expand Up @@ -53,14 +53,16 @@ def parallelize_with_progress(scope)

progress.log("Processing #{item.id}") if options[:verbose]

result = ActiveRecord::Base.connection_pool.with_connection do
yield(item)
ensure
RedisConfiguration.pool.checkin if Thread.current[:redis]
Thread.current[:redis] = nil
Chewy.strategy(:mastodon) do
result = ActiveRecord::Base.connection_pool.with_connection do
yield(item)
ensure
RedisConfiguration.pool.checkin if Thread.current[:redis]
Thread.current[:redis] = nil
end

aggregate.increment(result) if result.is_a?(Integer)
end

aggregate.increment(result) if result.is_a?(Integer)
rescue => e
progress.log pastel.red("Error processing #{item.id}: #{e}")
ensure
Expand Down

0 comments on commit b97e63d

Please sign in to comment.