Skip to content

Commit

Permalink
Remove retrying on creating events
Browse files Browse the repository at this point in the history
If saving an event results in an ActiveRecord::StatementInvalid
exception, just retrying to save that event 10 times doesn't make a
difference.

Also, don't rescue from StandardError exceptions to handle them exactly
as we do in the rest of the application.
  • Loading branch information
eduardoj committed Jan 24, 2025
1 parent 09f7c57 commit 4158b17
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/api/app/models/update_notification_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,8 @@ def create_events
e.elements('data') do |d|
data[d['key']] = d['_content']
end
retries = 10
begin
event = Event::Factory.new_from_type(type, data)
event.save!
rescue ActiveRecord::StatementInvalid => e
retries -= 1
if retries.positive?
Airbrake.notify("Failed to create Event : #{type.inspect}: #{data} #{e}")
retry
end
Airbrake.notify("Failed to create Event : #{type.inspect}: #{data} #{e}")
rescue StandardError => e
Airbrake.notify("Failed to create Event : #{type.inspect}: #{data} #{e}")
end
event = Event::Factory.new_from_type(type, data)
event.save!
end
end

Expand Down

0 comments on commit 4158b17

Please sign in to comment.