BURs: lock posts when updating tags during bulk updates.

Fixes updates sometimes getting clobbered when multiple aliases or mass
updates tried to update the same post at the same time.
This commit is contained in:
evazion
2019-12-27 12:08:17 -06:00
parent 3b4f9ad086
commit 06e12973e2
4 changed files with 14 additions and 22 deletions

View File

@@ -28,9 +28,10 @@ class TagBatchChangeJob < ApplicationJob
def migrate_posts(normalized_antecedent, normalized_consequent)
::Post.tag_match(normalized_antecedent.join(" ")).find_each do |post|
post.reload
tags = (post.tag_array - normalized_antecedent + normalized_consequent).join(" ")
post.update(tag_string: tags)
post.with_lock do
tags = (post.tag_array - normalized_antecedent + normalized_consequent).join(" ")
post.update(tag_string: tags)
end
end
end