File tree Expand file tree Collapse file tree 2 files changed +13
-1
lines changed
Expand file tree Collapse file tree 2 files changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,10 @@ module BetterTogether
55 # This job is responsible for indexing and deleting documents in Elasticsearch
66 # when records are created, updated, or destroyed.
77 class ElasticsearchIndexJob < ApplicationJob
8- queue_as :default
8+ queue_as :es_indexing
9+
10+ # Don't retry on deserialization errors - the record no longer exists
11+ discard_on ActiveJob ::DeserializationError
912
1013 def perform ( record , action )
1114 return unless record . respond_to? :__elasticsearch__
@@ -18,6 +21,9 @@ def perform(record, action)
1821 else
1922 raise ArgumentError , "Unknown action: #{ action } "
2023 end
24+ rescue ActiveRecord ::RecordNotFound
25+ # Record was deleted before the job could run - this is expected for delete operations
26+ Rails . logger . info "ElasticsearchIndexJob: Record no longer exists, skipping #{ action } operation"
2127 end
2228 end
2329end
Original file line number Diff line number Diff line change @@ -6,9 +6,15 @@ class GeocodingJob < ApplicationJob # rubocop:todo Style/Documentation
66 queue_as :geocoding
77 retry_on StandardError , wait : :polynomially_longer , attempts : 5
88
9+ # Don't retry on deserialization errors - the record no longer exists
10+ discard_on ActiveJob ::DeserializationError
11+
912 def perform ( geocodable )
1013 coords = geocodable . geocode
1114 geocodable . save if coords
15+ rescue ActiveRecord ::RecordNotFound
16+ # Record was deleted before the job could run
17+ Rails . logger . info 'GeocodingJob: Record no longer exists, skipping geocoding operation'
1218 end
1319 end
1420 end
You can’t perform that action at this time.
0 commit comments