From 961c892bd16026c4bf754b07200531339dcb0e5f Mon Sep 17 00:00:00 2001 From: Andy Wallace Date: Thu, 14 Mar 2024 10:26:21 -0400 Subject: [PATCH 1/2] in Californica::Deleter, recover from RSolr http errors https://uclalibrary.atlassian.net/browse/APPS-2612 --- app/lib/californica/deleter.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/lib/californica/deleter.rb b/app/lib/californica/deleter.rb index 79201b36..4758e17f 100644 --- a/app/lib/californica/deleter.rb +++ b/app/lib/californica/deleter.rb @@ -82,12 +82,13 @@ def destroy_and_eradicate Hyrax.config.callback.run(:after_destroy, record.id, User.batch_user) log("Deleted #{record.class} #{record.id} in #{ActiveSupport::Duration.build(Time.current - start_time)}") log("deleted item ark is: #{record.ark}") - rescue Ldp::HttpError, Faraday::TimeoutError, Faraday::ConnectionFailed => e + rescue Ldp::HttpError, Faraday::TimeoutError, Faraday::ConnectionFailed, RSolr::Error::Http => e log("#{e.class}: #{e.message}") retries ||= 0 if (retries += 1) > 3 return false # Explicitly return false after retries are exhausted else + sleep(10**(retries - 1)) retry end end From 290acc6ed5728f5a62a9ca1441c8062feceac198 Mon Sep 17 00:00:00 2001 From: Andy Wallace Date: Thu, 21 Mar 2024 13:14:19 -0400 Subject: [PATCH 2/2] fix: simplify Californica::Deleter.delete_collection_with_works calls delete() instead of delete_with_children() for each work in the collection. --- app/lib/californica/deleter.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/app/lib/californica/deleter.rb b/app/lib/californica/deleter.rb index 4758e17f..9a141c14 100644 --- a/app/lib/californica/deleter.rb +++ b/app/lib/californica/deleter.rb @@ -15,6 +15,7 @@ def initialize(id: nil, record: nil, logger: Rails.logger) end def delete + log("Californica::Deleter.delete: deleting #{@id}") destroy_and_eradicate end @@ -36,8 +37,9 @@ def delete_collection_with_works(of_type: nil) # Ensures all works are deleted; returns true if successful def delete_works(of_type: nil) work_id_list.empty? || work_id_list.all? do |work_id| + log("Californica::Deleter.delete_works: deleting work #{work_id}") Californica::Deleter.new(id: work_id, logger: logger) - .delete_with_children(of_type: of_type) + .delete(of_type: of_type) end end @@ -77,6 +79,7 @@ def deletion_type_matches?(of_type) end def destroy_and_eradicate + log("Californica::Deleter.destroy_and_eradicate: #{@id}") start_time = Time.current record&.destroy&.eradicate Hyrax.config.callback.run(:after_destroy, record.id, User.batch_user) @@ -97,6 +100,7 @@ def delete_from_fcrepo ActiveFedora.fedora.connection.delete(ActiveFedora::Base.id_to_uri(id)) log("Forced delete of record from Fedora") rescue Ldp::NotFound + log("Record not found in Fedora") nil # Everything's good, we just wanted to make sure there wasn't a record in fedora not indexed to solr end @@ -112,7 +116,8 @@ def log(message, status: :info) def record @record ||= ActiveFedora::Base.find(id) - rescue ActiveFedora::ObjectNotFoundError + rescue ActiveFedora::ObjectNotFoundError => e + log(e, status: :error) delete_from_fcrepo end