zulip
zulip copied to clipboard
Set an optional max connection lifetime for SMTP connections
Zulip's email_senders
worker process opens an SMTP connection on start-up, and re-checks that connection is still live with a NOOP
command immediately before attempting to re-use it every time:
https://github.com/zulip/zulip/blob/77fd03e426e75b5914bece7da46a3bbaa8121f17/zerver/worker/queue_processors.py#L735-L751
https://github.com/zulip/zulip/blob/77fd03e426e75b5914bece7da46a3bbaa8121f17/zerver/lib/send_email.py#L294-L331
However, some SMTP servers react poorly to long-lived connections, closing connections not based on idle time, but rather connection time. This can result in connections dropping mid-send, which leaves it unclear to Zulip if the message has been processed or not.
We should add a configuration option which controls the max lifetime (in minutes) which we will reuse an open SMTP connection. If the connection has been open longer than this threshold, we should close the old connection and re-open a new one. If the setting is 0, we should tear open and close SMTP connections as needed, and never keep them open.
We should probably default this setting to 0, because the connection keep-alive is an optimization that most small installs won't need.
Hello @zulip/server-production members, this issue was labeled with the "area: production" label, so you may want to check it out!
I'd like to try this one :) @zulipbot claim
Welcome to Zulip, @tal66! We just sent you an invite to collaborate on this repository at https://github.com/zulip/zulip/invitations. Please accept this invite in order to claim this issue and begin a fun, rewarding experience contributing to Zulip!
Here's some tips to get you off to a good start:
- Join me on the Zulip developers' server, to get help, chat about this issue, and meet the other developers.
- Unwatch this repository, so that you don't get 100 emails a day.
As you work on this issue, you'll also want to refer to the Zulip code contribution guide, as well as the rest of the developer documentation on that site.
See you on the other side (that is, the pull request side)!
@tal66 You have been unassigned from this issue because you have not made any updates for over 14 days. Please feel free to reclaim the issue if you decide to pick up again. Thanks!
.
@zulipbot claim
Hello @qiqistyle, it looks like you've currently claimed 1 issue in this repository. We encourage new contributors to focus their efforts on at most 1 issue at a time, so please complete your work on your other claimed issues before trying to claim this issue again.
We look forward to your valuable contributions!
@zulipbot claim
@swayam0322 You have been unassigned from this issue because you have not made any updates for over 14 days. Please feel free to reclaim the issue if you decide to pick up again. Thanks!
We should probably default this setting to 0, because the connection keep-alive is an optimization that most small installs won't need.
Should we keep the default as None
in the beginning? where None defaults to the existing behaviour of not closing the connection. This might help to avoid any unexpected changes for people with large-ish installs. Or would this setting only impact zulip cloud in a meaningful way?