FIX: Prevent race condition when post processing post (#8819)

If a post is being cooked twice (for example after an edit), there is a
chance the 'raw' and 'cooked' column to be inconsistent. This reduces
the chances of that happening.
This commit is contained in:
Bianca Nenciu 2020-03-07 14:36:54 +02:00 committed by GitHub
parent e9b6b0194c
commit f14dd1f82d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 35 additions and 33 deletions

View File

@ -7,6 +7,7 @@ module Jobs
class ProcessPost < ::Jobs::Base
def execute(args)
DistributedMutex.synchronize("process_post_#{args[:post_id]}") do
post = Post.find_by(id: args[:post_id])
# two levels of deletion
return unless post.present? && post.topic.present?
@ -47,6 +48,7 @@ module Jobs
end
end
end
end
# onebox may have added some links, so extract them now
def extract_links(post)