Skip to content

AlgoliaJob for the deleted record always rise ActiveJob::DeserializationError #359

@zhukovpe

Description

@zhukovpe
  • 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:...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions