From 42e959710d6e4cfa50ea24363fe24fb1c94d7e8a Mon Sep 17 00:00:00 2001
From: Eduardo Navarro <enavarro@suse.com>
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.
---
 .../app/models/update_notification_events.rb  | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)

diff --git a/src/api/app/models/update_notification_events.rb b/src/api/app/models/update_notification_events.rb
index 2222a34f6056..e33b2f57ef44 100644
--- a/src/api/app/models/update_notification_events.rb
+++ b/src/api/app/models/update_notification_events.rb
@@ -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