algoliasearch-rails
algoliasearch-rails copied to clipboard
AlgoliaJob for the deleted record always rise ActiveJob::DeserializationError
- 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
- 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
- Create an object, destroy an object.
s = School.create(
title: 'Fancy',
street: 'Claude Bernard',
zipcode: '75005',
city: 'Paris'
)
s.destroy
- Ensure the job fails within your asynchronous worker
ActiveJob::DeserializationError: Error while trying to deserialize arguments:...
have you resolved it?
have you resolved it?
made a PR https://github.com/algolia/algoliasearch-rails/pull/369
Does anyone have a (temporary) workaround for this issue?
I'm now frequently exceeding my quota, because old records don't get deleted.