mirror of https://github.com/zulip/zulip.git
6f20c15ae9
Messages are rendered outside of a transaction, for performance reasons, and then sent inside of one. This opens thumbnailing up to a race where the thumbnails have not yet been written when the message is rendered, but the message has not been sent when thumbnailing completes, causing `rewrite_thumbnailed_images` to be a no-op and the message being left with a spinner which never resolves. Explicitly lock and use he ImageAttachment data inside the message-sending transaction, to rewrite the message content with the latest information about the existing thumbnails. Despite the thumbnailing worker taking a lock on Message rows to update them, this does not lead to deadlocks -- the INSERT of the Message rows happens in a transaction, ensuring that either the message rending blocks the thumbnailing until the Message row is created, or that the `rewrite_thumbnailed_images` and Message INSERT waits until thumbnailing is complete (and updated no Message rows). |
||
---|---|---|
.. | ||
__init__.py | ||
base.py | ||
deferred_work.py | ||
digest_emails.py | ||
email_mirror.py | ||
email_senders.py | ||
embed_links.py | ||
embedded_bots.py | ||
missedmessage_emails.py | ||
missedmessage_mobile_notifications.py | ||
outgoing_webhooks.py | ||
queue_processors.py | ||
test.py | ||
thumbnail.py | ||
user_activity.py | ||
user_activity_interval.py |