diff options
| author | Stan Hu <stanhu@gmail.com> | 2017-12-17 15:17:55 -0800 |
|---|---|---|
| committer | Stan Hu <stanhu@gmail.com> | 2018-01-03 22:49:02 -0800 |
| commit | 57dc5a521bbdd94cc2eab34f22e2b6fac9e8bd55 (patch) | |
| tree | 41c79b0f44b232eee0ce3e6b543e15517ff98492 /lib | |
| parent | 54bc270f7e90f4bd15d6958e44d0a8f41a3eb571 (diff) | |
| download | gitlab-ce-57dc5a521bbdd94cc2eab34f22e2b6fac9e8bd55.tar.gz | |
Avoid leaving a push event empty if payload cannot be createdsh-validate-path-project-import
If the payload cannot be created for some reason, we could be left with a nil
push event payload, which causes Error 500s when viewing the dashboard. Guard
against this error and log when it happens.
Avoids problems seen in #38823
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/gitlab/background_migration/migrate_events_to_push_event_payloads.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/gitlab/background_migration/migrate_events_to_push_event_payloads.rb b/lib/gitlab/background_migration/migrate_events_to_push_event_payloads.rb index 84ac00f1a5c..7088aa0860a 100644 --- a/lib/gitlab/background_migration/migrate_events_to_push_event_payloads.rb +++ b/lib/gitlab/background_migration/migrate_events_to_push_event_payloads.rb @@ -128,8 +128,14 @@ module Gitlab end def process_event(event) - replicate_event(event) - create_push_event_payload(event) if event.push_event? + ActiveRecord::Base.transaction do + replicate_event(event) + create_push_event_payload(event) if event.push_event? + end + rescue ActiveRecord::InvalidForeignKey => e + # A foreign key error means the associated event was removed. In this + # case we'll just skip migrating the event. + Rails.logger.error("Unable to migrate event #{event.id}: #{e}") end def replicate_event(event) @@ -137,9 +143,6 @@ module Gitlab .with_indifferent_access.except(:title, :data) EventForMigration.create!(new_attributes) - rescue ActiveRecord::InvalidForeignKey - # A foreign key error means the associated event was removed. In this - # case we'll just skip migrating the event. end def create_push_event_payload(event) @@ -156,9 +159,6 @@ module Gitlab ref: event.trimmed_ref_name, commit_title: event.commit_title ) - rescue ActiveRecord::InvalidForeignKey - # A foreign key error means the associated event was removed. In this - # case we'll just skip migrating the event. end def find_events(start_id, end_id) |
