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 Oct 15, 2024
1 parent df88d32 commit 42e9597
Showing 1 changed file with 2 additions and 17 deletions.
19 changes: 2 additions & 17 deletions src/api/app/models/update_notification_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +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
retry if retries.positive?
Airbrake.notify("Failed to create Event : #{type.inspect}: #{data} #{e}")
rescue StandardError => e
if Rails.env.test?
# make debug output useful in test suite, not just showing backtrace to Airbrake
Rails.logger.error "ERROR: #{e.inspect}: #{e.backtrace}"
Rails.logger.info e.inspect
Rails.logger.info e.backtrace
end
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 42e9597

Please sign in to comment.