We're migrating off of Paperclip and while I appreciate their migration guide to move to ActiveStorage, it would require several hours of downtime for us which was an immediate non-starter. As a result, I ended up writing some very hacky code to keep our models on Paperclip while also creating the appropriate Blob and Attachment records in the DB so we can switch over to ActiveStorage seamlessly. I have a hunch that some of that hacky code is creating excess blobs in certain circumstances which is leading to a relatively large number of failed jobs.
In case you're interested, our migration logic looks something like: 1. Monkey patch Paperclip so it calls an extra function every time it tries to write a new asset 2. In that extra function, call ActiveStorage::Blob.create_after_upload! and ActiveStorage::Attachment.create with some reasonable arguments. 3. Write some rake tasks that resave all of our existing Paperclip attachments which will cause them to all get re-saved under ActiveStorage. 4. Update our code to use ActiveStorage (has_attached_file -> has_one_attached, etc.) On Tue, Feb 12, 2019 at 8:49 PM George Claghorn <geo...@basecamp.com> wrote: > Do you know why the AnalyzeJobs are failing to find their blobs? Are you > deleting blobs immediately after creating them, or...? > > On Tue, Feb 12, 2019 at 11:03 AM smarder via Ruby on Rails: Core < > rubyonrails-core@googlegroups.com> wrote: > >> I have a growing list of failed ActiveStorage::AnalyzeJob jobs that have >> all failed with >> >> ActiveJob::DeserializationError: Error while trying to deserialize >> arguments: Couldn't find ActiveStorage::Blob with 'id'=XXXX >> >> After poking around a bit, I discovered that this is a documented >> situation and expected behavior: >> https://github.com/rails/rails/commit/5e2273f42ce2382023f90fe4f0fbceec5c3416d5 >> . >> >> However, I was looking at ActiveStorage::PurgeJob and noticed that it >> includes discard_on ActiveRecord::RecordNotFound >> <https://github.com/rails/rails/blob/ad3cbc2452e8150542ecb539925396361f12534c/activestorage/app/jobs/active_storage/purge_job.rb#L7> >> . >> >> My question is this: Is there a good reason that the AnalyzeJob doesn't >> silently drop jobs that will never run even though PurgeJob does? And if >> there isn't, would someone be willing to approve the feature assuming I >> made a PR for it? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Ruby on Rails: Core" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to rubyonrails-core+unsubscr...@googlegroups.com. >> To post to this group, send email to rubyonrails-core@googlegroups.com. >> Visit this group at https://groups.google.com/group/rubyonrails-core. >> For more options, visit https://groups.google.com/d/optout. >> > -- > You received this message because you are subscribed to a topic in the > Google Groups "Ruby on Rails: Core" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/rubyonrails-core/EUvn3vjk7yA/unsubscribe > . > To unsubscribe from this group and all its topics, send an email to > rubyonrails-core+unsubscr...@googlegroups.com. > To post to this group, send email to rubyonrails-core@googlegroups.com. > Visit this group at https://groups.google.com/group/rubyonrails-core. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at https://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.