<p></p>
<p><b>@gravitystorm</b> requested changes on this pull request.</p>

<p dir="auto">Overall I'm a bit nervous about this. Having a quick read around, <code class="notranslate">ActiveJob::DeserializationError</code> can be triggered by all kinds of connection errors. For example, some developers in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="724126601" data-permission-text="Title is private" data-url="https://github.com/getsentry/sentry-ruby/issues/1071" data-hovercard-type="issue" data-hovercard-url="/getsentry/sentry-ruby/issues/1071/hovercard" href="https://github.com/getsentry/sentry-ruby/issues/1071">getsentry/sentry-ruby#1071</a> were discussing when they received the following:</p>
<blockquote>
<p dir="auto">ActiveJob::DeserializationError: Error while trying to deserialize arguments: could not obtain a connection from the pool within 5.000 seconds (waited 5.295 seconds); all pooled connections were in use</p>
</blockquote>
<p dir="auto">I'd hate to think that a db connection hiccup could cause thousands of legitimate jobs to be discarded!</p>
<p dir="auto">There's a suggestion in that thread that you can catch a different error, e.g.<br>
<code class="notranslate">discard_on ActiveRecord::RecordNotFound</code> but that also leaves me worried, since that error might not be from the deserialisation, but instead from some other logic problem in the rest of the job code.</p>
<p dir="auto"><a href="https://edgeapi.rubyonrails.org/classes/ActiveJob/DeserializationError.html" rel="nofollow">The docs for <code class="notranslate">ActiveJob:DeserializationError</code></a> suggest that the original error is available wrapped within that one, so perhaps it might be possible to discard only the jobs that raise a NotFound error during deserialization?</p><hr>

<p>In <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4323#discussion_r1394144523">app/mailers/application_mailer.rb</a>:</p>
<pre style='color:#555'>> @@ -1,2 +1,3 @@
 class ApplicationMailer < ActionMailer::Base
+  self.delivery_job = ActionMailer::MailDeliveryJob
</pre>
<p dir="auto">Should this not be <code class="notranslate">self.delivery_job = MailDeliveryJob</code> i.e. referencing our custom job class that has the discard_on configuration? Otherwise I don't think anything has changed.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />Reply to this email directly, <a href="https://github.com/openstreetmap/openstreetmap-website/pull/4323#pullrequestreview-1731944532">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/AAK2OLO3WHOQT5RG6XV77PLYES2XBAVCNFSM6AAAAAA65PHJVGVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTOMZRHE2DINJTGI">unsubscribe</a>.<br />You are receiving this because you are subscribed to this thread.<img src="https://github.com/notifications/beacon/AAK2OLMUFQI5EITVJJHJDITYES2XBA5CNFSM6AAAAAA65PHJVGWGG33NNVSW45C7OR4XAZNRKB2WY3CSMVYXKZLTORJGK5TJMV32UY3PNVWWK3TUL5UWJTTHHNQFI.gif" height="1" width="1" alt="" /><span style="color: transparent; font-size: 0; display: none; visibility: hidden; overflow: hidden; opacity: 0; width: 0; height: 0; max-width: 0; max-height: 0; mso-hide: all">Message ID: <span><openstreetmap/openstreetmap-website/pull/4323/review/1731944532</span><span>@</span><span>github</span><span>.</span><span>com></span></span></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/openstreetmap/openstreetmap-website/pull/4323#pullrequestreview-1731944532",
"url": "https://github.com/openstreetmap/openstreetmap-website/pull/4323#pullrequestreview-1731944532",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>