algoliasearch-rails icon indicating copy to clipboard operation
algoliasearch-rails copied to clipboard

AlgoliaJob for the deleted record always rise ActiveJob::DeserializationError

Open zhukovpe opened this issue 5 years ago • 3 comments

  • Rails version: 4.2.11.1
  • Algolia Rails integration version: 1.18.0
  • Algolia Client Version: 1.12.5
  • Language Version: 2.4.6

Description

Asynchronous index update enqueues a job with the specific object instance as a parameter. This specific object cannot be deserialized from the parameter during job processing for the deleted record. An asynchronous index update job for the deleted record will always fail.

A possible solution according to job guidelines could be to enqueue a job with the record identifier as a parameter, not the instance itself. Decouple index update logic from the model and use this logic inside job. We need only an ID to delete a record from the index, not the object itself.

Steps To Reproduce

  1. Create a simple model with the Algolia included and configured to update the index asynchronously
class School
  include Mongoid::Document
  include AlgoliaSearch

  field :title,                type: String
  field :description,          type: String
  field :street,               type: String
  field :zipcode,              type: String
  field :city,                 type: String

  algoliasearch per_environment: true, enqueue: true do
    attributes :title, :street, :zipcode, :city
  end
end
  1. Create an object, destroy an object.
s = School.create(
  title: 'Fancy',
  street: 'Claude Bernard',
  zipcode: '75005',
  city: 'Paris'
)
s.destroy
  1. Ensure the job fails within your asynchronous worker
ActiveJob::DeserializationError: Error while trying to deserialize arguments:...

zhukovpe avatar Jul 11 '19 08:07 zhukovpe

have you resolved it?

balakirevs avatar Aug 25 '19 14:08 balakirevs

have you resolved it?

made a PR https://github.com/algolia/algoliasearch-rails/pull/369

zhukovpe avatar Oct 17 '19 12:10 zhukovpe

Does anyone have a (temporary) workaround for this issue?

I'm now frequently exceeding my quota, because old records don't get deleted.

marckohlbrugge avatar Feb 13 '21 13:02 marckohlbrugge