From 7344369fbb93ced1f85f18491e6837bbf4b79f16 Mon Sep 17 00:00:00 2001 From: Eduardo Navarro Date: Tue, 15 Oct 2024 13:18:04 +0200 Subject: [PATCH] Remove retrying on creating events 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. --- src/api/app/models/update_notification_events.rb | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/src/api/app/models/update_notification_events.rb b/src/api/app/models/update_notification_events.rb index e6ec1c07579..e33b2f57ef4 100644 --- a/src/api/app/models/update_notification_events.rb +++ b/src/api/app/models/update_notification_events.rb @@ -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