zulip/zerver/worker
Alex Vandiver 6f20c15ae9 thumbnail: Resolve a race condition when rendering messages.
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).
2024-08-01 16:48:16 -07:00
..
__init__.py
base.py ruff: Fix SIM117 Use a single `with` statement with multiple contexts. 2024-07-14 13:48:32 -07:00
deferred_work.py ruff: Fix UP006 Use `list` instead of `List` for type annotation. 2024-07-13 22:28:22 -07:00
digest_emails.py ruff: Fix UP035 Import from `collections.abc`, `typing` instead. 2024-07-13 22:28:22 -07:00
email_mirror.py ruff: Fix UP035 Import from `collections.abc`, `typing` instead. 2024-07-13 22:28:22 -07:00
email_senders.py ruff: Fix UP035 Import from `collections.abc`, `typing` instead. 2024-07-13 22:28:22 -07:00
embed_links.py markdown: Show thumbnails for uploaded images. 2024-07-21 18:41:59 -07:00
embedded_bots.py ruff: Fix UP035 Import from `collections.abc`, `typing` instead. 2024-07-13 22:28:22 -07:00
missedmessage_emails.py ruff: Fix UP007 Use `X | Y` for type annotations. 2024-07-13 22:28:22 -07:00
missedmessage_mobile_notifications.py ruff: Fix PLR6104 Use `+=` to perform an augmented assignment directly. 2024-07-14 13:49:51 -07:00
outgoing_webhooks.py ruff: Fix UP006 Use `list` instead of `List` for type annotation. 2024-07-13 22:28:22 -07:00
queue_processors.py ruff: Fix UP007 Use `X | Y` for type annotations. 2024-07-13 22:28:22 -07:00
test.py ruff: Fix UP035 Import from `collections.abc`, `typing` instead. 2024-07-13 22:28:22 -07:00
thumbnail.py thumbnail: Resolve a race condition when rendering messages. 2024-08-01 16:48:16 -07:00
user_activity.py ruff: Fix UP006 Use `list` instead of `List` for type annotation. 2024-07-13 22:28:22 -07:00
user_activity_interval.py ruff: Fix UP035 Import from `collections.abc`, `typing` instead. 2024-07-13 22:28:22 -07:00