[openstreetmap/openstreetmap-website] Discard jobs when then encounter a deserialization error (PR #4323)

Andy Allan notifications at github.com
Wed Nov 15 12:47:44 UTC 2023


@gravitystorm requested changes on this pull request.

Overall I'm a bit nervous about this. Having a quick read around, `ActiveJob::DeserializationError` can be triggered by all kinds of connection errors. For example, some developers in https://github.com/getsentry/sentry-ruby/issues/1071 were discussing when they received the following:

> 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

I'd hate to think that a db connection hiccup could cause thousands of legitimate jobs to be discarded! 

There's a suggestion in that thread that you can catch a different error, e.g.
`discard_on ActiveRecord::RecordNotFound` 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.

[The docs for `ActiveJob:DeserializationError`](https://edgeapi.rubyonrails.org/classes/ActiveJob/DeserializationError.html) 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?

> @@ -1,2 +1,3 @@
 class ApplicationMailer < ActionMailer::Base
+  self.delivery_job = ActionMailer::MailDeliveryJob

Should this not be `self.delivery_job = MailDeliveryJob` i.e. referencing our custom job class that has the discard_on configuration? Otherwise I don't think anything has changed.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/4323#pullrequestreview-1731944532
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/4323/review/1731944532 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20231115/ff4c3ce9/attachment.htm>


More information about the rails-dev mailing list