zulip/scripts/lib
Alex Vandiver c5200e8b05 deliver_scheduled_emails: Use a queue, instead of infinite retries.
`deliver_scheduled_emails` tries to deliver the email synchronously,
and if it fails, it retries after 10 seconds.  Since it does not track
retries, and always tries the earliest-scheduled-but-due message
first, the worker will not make forward progress if there is a
persistent failure with that message, and will retry indefinitely.
This can result in excessive network or email delivery charges from
the remote SMTP server.

Switch to delivering emails via a new queue worker.  The
`deliver_scheduled_emails` job now serves only to pull deferred jobs
out of the table once they are due, insert them into RabbitMQ, and
then delete them.  This limits the potential for head-of-queue
failures to failures inserting into RabbitMQ, which is more reasonable
than failures speaking to a complex external system we do not control.
Retries and any connections to the SMTP server are left to the
RabbitMQ consumer.

We build a new RabbitMQ queue, rather than use the existing
`email_senders` queue, because that queue is expected to be reasonably
low-latency, for things like missed message notifications.  The
`send_future_email` codepath which inserts into ScheduledEmails is
also (ab)used to digest emails, which are extremely bursty in their
frequency -- and a large burst could significantly delay emails behind
it in the queue.

The new queue is explicitly only for messages which were not initiated
by user actions (e.g., invitation reminders, digests, new account
follow-ups) which are thus not latency-sensitive.

Fixes: #32463.
2025-03-04 16:09:25 -08:00
..
__init__.py Factor out venv-creating code from provision.py. 2016-06-21 11:25:41 -07:00
build-groonga provision: Add provision support for Fedora 38. 2023-08-22 11:26:29 -07:00
build-pgroonga build-pgroonga: Upgrade PGroonga from 3.1.0 to 3.1.8. 2024-03-01 17:38:08 -08:00
check_rabbitmq_queue.py deliver_scheduled_emails: Use a queue, instead of infinite retries. 2025-03-04 16:09:25 -08:00
check-database-compatibility check-database-compatibility: Refactor a STALE_MIGRATIONS. 2025-01-24 17:08:37 -08:00
clean_emoji_cache.py ruff: Fix UP006 Use list instead of List for type annotation. 2024-07-13 22:28:22 -07:00
clean_unused_caches.py clean_node_cache: Remove. 2025-02-19 16:44:02 -08:00
clean_venv_cache.py requirements: Migrate to uv. 2025-02-24 22:29:24 -08:00
create-production-venv requirements: Migrate to uv. 2025-02-24 22:29:24 -08:00
email-mirror-postfix typos: Fix typos caught by mwic. 2024-05-20 13:55:00 -07:00
fix-standalone-certbot puppet: Fix standalone certbot configurations. 2022-01-24 12:13:44 -08:00
hash_reqs.py ruff: Fix UP035 Import from collections.abc, typing instead. 2024-07-13 22:28:22 -07:00
install install: Remove --cacert and CUSTOM_CA_CERTIFICATES. 2025-02-24 22:29:24 -08:00
install-node install-node: Upgrade Node.js from 22.12.0 to 22.14.0. 2025-02-26 16:20:47 -08:00
install-uv requirements: Migrate to uv. 2025-02-24 22:29:24 -08:00
node_cache.py install-node: Upgrade Node.js from 22.12.0 to 22.14.0. 2025-02-26 16:20:47 -08:00
puppet_cache.py Remove support for Ubuntu 20.04 and Debian 11. 2024-04-01 13:27:39 -07:00
pythonrc.py pythonrc: Add various frequently handy imports. 2024-03-27 12:49:24 -07:00
queue_workers.py python: Normalize quotes with Black. 2021-02-12 13:11:19 -08:00
run_hooks.py run_hooks: Pass down, and respect, --from-git argument. 2025-03-04 13:18:50 -08:00
setup_path.py requirements: Migrate to uv. 2025-02-24 22:29:24 -08:00
setup_venv.py requirements: Migrate to uv. 2025-02-24 22:29:24 -08:00
setup-apt-repo apt-repos: Temporarily work around Ubuntu 24.04 non-installable gnupg. 2024-03-31 13:51:31 -07:00
setup-yum-repo provision: Add support for Fedora 34. 2021-07-20 12:10:41 -07:00
sharding.py python: Simplify with str.removeprefix, str.removesuffix. 2024-09-03 12:30:16 -07:00
supervisor.py python: Simplify with str.removeprefix, str.removesuffix. 2024-09-03 12:30:16 -07:00
supported-os install: Check for a supported version of the OS in shell. 2024-04-16 11:13:33 -07:00
unpack-zulip ruff: Fix UP032 Use f-string instead of format call. 2023-08-02 15:58:55 -07:00
update-git-upstream upgrade-zulip-from-git: Extract code to set zulip upstream remote. 2023-04-19 16:56:14 -07:00
upgrade-zulip typos: Fix typos caught by mwic. 2024-05-20 13:55:00 -07:00
upgrade-zulip-from-git python: Simplify with str.removeprefix, str.removesuffix. 2024-09-03 12:30:16 -07:00
upgrade-zulip-stage-2 upgrade-zulip-stage-2: Be more specific about OS upgrade steps. 2024-07-26 11:14:11 -07:00
upgrade-zulip-stage-3 run_hooks: Pass down, and respect, --from-git argument. 2025-03-04 13:18:50 -08:00
warn-rabbitmq-nodename-change puppet: Always set the RabbitMQ nodename to zulip@localhost. 2022-01-25 01:48:02 +00:00
zulip_tools.py cache: Flush caches from all known key prefixes. 2025-02-21 14:11:08 -08:00