Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

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 authored Mar 20, 2023
1 parent 0ca54a4 commit bdeb6ff
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/mastodon/cli_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,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 bdeb6ff

Please sign in to comment.