The improvement affects the code that checks at the end of an ImportSubscriptionWorker if the OpmlImportJobState for the whole OPML import exists and is in state RUNNING. The old code could raise an ActiveRecord::RecordNotFound error if the OpmlImportJobState is destroyed during the import of the feed.
Now the first thing the worker does in the sanity check is to ensure that the OpmlImportJobState still exists, then it checks that it is in state RUNNING, and finally updates the total count of processed feeds for the OPML import. If any of those checks fails, a message is logged and the worker stops without an error.
The old behavior was not exactly wrong, but the raised error meant that the worker was retried by Sidekiq; the next run would do nothing because the fact that the OpmlImportJobState no longer exists would be caught by the sanity checks at the beginning of the worker, but it's still better not to retry jobs that we know cannot succeed.
↧