mirror of https://github.com/zulip/zulip.git
embed_links: Take a lock on the message object while editing.
We leave the fetching of links outside of the lock, as they could take seconds, which is an unreasonable amount of time to hold a lock on the message row. This may result in unnecessary work, in the case that the message was since edited, but the unnecessary work is preferable to blocking other work on the message row for the duration.
This commit is contained in:
parent
62642b899c
commit
de63000db6
|
@ -869,12 +869,16 @@ class FetchLinksEmbedData(QueueProcessingWorker):
|
|||
"Time spent on get_link_embed_data for %s: %s", url, time.time() - start_time
|
||||
)
|
||||
|
||||
message = Message.objects.get(id=event["message_id"])
|
||||
with transaction.atomic():
|
||||
message = Message.objects.select_for_update().get(id=event["message_id"])
|
||||
# If the message changed, we will run this task after updating the message
|
||||
# in zerver.actions.message_edit.check_update_message
|
||||
if message.content != event["message_content"]:
|
||||
return
|
||||
if message.content is not None:
|
||||
|
||||
if message.content is None:
|
||||
return
|
||||
|
||||
query = UserMessage.objects.filter(
|
||||
message=message.id,
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue