From 87ae86b973ecfbd0d9e5be42d5905ecd01443ac5 Mon Sep 17 00:00:00 2001 From: Martin Fenner Date: Thu, 24 Dec 2020 18:08:14 +0100 Subject: [PATCH] handle indexing errors. #690 --- app/models/datacite_doi.rb | 7 ++++++- app/models/other_doi.rb | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/models/datacite_doi.rb b/app/models/datacite_doi.rb index eacc5b5e1..84ecd3142 100644 --- a/app/models/datacite_doi.rb +++ b/app/models/datacite_doi.rb @@ -54,6 +54,8 @@ def self.import_by_ids(options = {}) logger.info "Queued importing for DataCite DOIs with IDs #{from_id}-#{until_id}." count + rescue Aws::SQS::Errors::RequestEntityTooLarge => e + Rails.logger.error "[Elasticsearch] Error #{e.class}: #{mapped_dois.bytesize} bytes" end def self.import_by_client(client_id) @@ -67,6 +69,8 @@ def self.import_by_client(client_id) end DataciteDoiImportInBulkJob.perform_later(mapped_dois, index: self.active_index) end + rescue Aws::SQS::Errors::RequestEntityTooLarge => e + Rails.logger.error "[Elasticsearch] Error #{e.class}: #{mapped_dois.bytesize} bytes" end def self.import_in_bulk(dois, options = {}) @@ -118,10 +122,11 @@ def self.import_in_bulk(dois, options = {}) count rescue Elasticsearch::Transport::Transport::Errors::RequestEntityTooLarge, + Aws::SQS::Errors::RequestEntityTooLarge, Faraday::ConnectionFailed, ActiveRecord::LockWaitTimeout => e - Rails.logger.error "[Elasticsearch] Error #{ + Rails.logger.error "[Elasticsearch] Error #{e.class} with message #{ e.message } importing DataCite DOIs." end diff --git a/app/models/other_doi.rb b/app/models/other_doi.rb index 7accc4b71..5f7a0c6ce 100644 --- a/app/models/other_doi.rb +++ b/app/models/other_doi.rb @@ -105,6 +105,8 @@ def self.import_by_ids(options = {}) logger.info "Queued importing for Other DOIs with IDs #{from_id}-#{until_id}." count + rescue Aws::SQS::Errors::RequestEntityTooLarge => e + Rails.logger.error "[Elasticsearch] Error #{e.class}: #{mapped_dois.bytesize} bytes" end def self.import_in_bulk(dois, options = {}) @@ -156,10 +158,11 @@ def self.import_in_bulk(dois, options = {}) count rescue Elasticsearch::Transport::Transport::Errors::RequestEntityTooLarge, + Aws::SQS::Errors::RequestEntityTooLarge, Faraday::ConnectionFailed, ActiveRecord::LockWaitTimeout => e - Rails.logger.error "[Elasticsearch] Error #{ + Rails.logger.error "[Elasticsearch] Error #{class} with message #{ e.message } importing Other DOIs." end