diff options
author | Reverite <github@reverite.sh> | 2019-03-21 15:35:55 -0700 |
---|---|---|
committer | Reverite <github@reverite.sh> | 2019-03-21 15:35:55 -0700 |
commit | 592735fd80acd0aeffb5a5674255ed48d7a8db0b (patch) | |
tree | 0eefc67f624a07df0af860edecd68d5dc64c7ee9 /app/workers | |
parent | 75eeb003b09c53d3b4e98046d1c20b0ad8a887bb (diff) | |
parent | bde9196b70299405ebe9b16500b7a3f65539b2c3 (diff) |
Merge remote-tracking branch 'glitch/master' into production
Diffstat (limited to 'app/workers')
-rw-r--r-- | app/workers/distribution_worker.rb | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/app/workers/distribution_worker.rb b/app/workers/distribution_worker.rb index f423d43ae..4e20ef31b 100644 --- a/app/workers/distribution_worker.rb +++ b/app/workers/distribution_worker.rb @@ -4,7 +4,13 @@ class DistributionWorker include Sidekiq::Worker def perform(status_id) - FanOutOnWriteService.new.call(Status.find(status_id)) + RedisLock.acquire(redis: Redis.current, key: "distribute:#{status_id}") do |lock| + if lock.acquired? + FanOutOnWriteService.new.call(Status.find(status_id)) + else + raise Mastodon::RaceConditionError + end + end rescue ActiveRecord::RecordNotFound true end |