Skip to content

Commit

Permalink
Rely on Rails.application.config.active_job.queue_adapter :inline beh…
Browse files Browse the repository at this point in the history
…avior rather than conditionally calling perform_now or perform_later based on Hyacinth queue_long_jobs config value; Fix test environment issue related to the :inline queue_adapter; Fix deprecation warning related to digital object destroy operations; Update rails gem to a newer patch release
  • Loading branch information
elohanlon committed Jan 3, 2025
1 parent 39d8d02 commit 65351d7
Show file tree
Hide file tree
Showing 8 changed files with 113 additions and 105 deletions.
150 changes: 75 additions & 75 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -36,40 +36,40 @@ GIT
GEM
remote: https://rubygems.org/
specs:
actioncable (6.1.7.6)
actionpack (= 6.1.7.6)
activesupport (= 6.1.7.6)
actioncable (6.1.7.10)
actionpack (= 6.1.7.10)
activesupport (= 6.1.7.10)
nio4r (~> 2.0)
websocket-driver (>= 0.6.1)
actionmailbox (6.1.7.6)
actionpack (= 6.1.7.6)
activejob (= 6.1.7.6)
activerecord (= 6.1.7.6)
activestorage (= 6.1.7.6)
activesupport (= 6.1.7.6)
actionmailbox (6.1.7.10)
actionpack (= 6.1.7.10)
activejob (= 6.1.7.10)
activerecord (= 6.1.7.10)
activestorage (= 6.1.7.10)
activesupport (= 6.1.7.10)
mail (>= 2.7.1)
actionmailer (6.1.7.6)
actionpack (= 6.1.7.6)
actionview (= 6.1.7.6)
activejob (= 6.1.7.6)
activesupport (= 6.1.7.6)
actionmailer (6.1.7.10)
actionpack (= 6.1.7.10)
actionview (= 6.1.7.10)
activejob (= 6.1.7.10)
activesupport (= 6.1.7.10)
mail (~> 2.5, >= 2.5.4)
rails-dom-testing (~> 2.0)
actionpack (6.1.7.6)
actionview (= 6.1.7.6)
activesupport (= 6.1.7.6)
actionpack (6.1.7.10)
actionview (= 6.1.7.10)
activesupport (= 6.1.7.10)
rack (~> 2.0, >= 2.0.9)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actiontext (6.1.7.6)
actionpack (= 6.1.7.6)
activerecord (= 6.1.7.6)
activestorage (= 6.1.7.6)
activesupport (= 6.1.7.6)
actiontext (6.1.7.10)
actionpack (= 6.1.7.10)
activerecord (= 6.1.7.10)
activestorage (= 6.1.7.10)
activesupport (= 6.1.7.10)
nokogiri (>= 1.8.5)
actionview (6.1.7.6)
activesupport (= 6.1.7.6)
actionview (6.1.7.10)
activesupport (= 6.1.7.10)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
Expand All @@ -93,22 +93,22 @@ GEM
active-fedora (>= 7.0.0)
activerecord
nokogiri
activejob (6.1.7.6)
activesupport (= 6.1.7.6)
activejob (6.1.7.10)
activesupport (= 6.1.7.10)
globalid (>= 0.3.6)
activemodel (6.1.7.6)
activesupport (= 6.1.7.6)
activerecord (6.1.7.6)
activemodel (= 6.1.7.6)
activesupport (= 6.1.7.6)
activestorage (6.1.7.6)
actionpack (= 6.1.7.6)
activejob (= 6.1.7.6)
activerecord (= 6.1.7.6)
activesupport (= 6.1.7.6)
activemodel (6.1.7.10)
activesupport (= 6.1.7.10)
activerecord (6.1.7.10)
activemodel (= 6.1.7.10)
activesupport (= 6.1.7.10)
activestorage (6.1.7.10)
actionpack (= 6.1.7.10)
activejob (= 6.1.7.10)
activerecord (= 6.1.7.10)
activesupport (= 6.1.7.10)
marcel (~> 1.0)
mini_mime (>= 1.1.0)
activesupport (6.1.7.6)
activesupport (6.1.7.10)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
Expand Down Expand Up @@ -150,7 +150,7 @@ GEM
bootstrap-sass (3.4.1)
autoprefixer-rails (>= 5.2.1)
sassc (>= 2.0.0)
builder (3.2.4)
builder (3.3.0)
byebug (11.1.3)
capistrano (3.18.0)
airbrussh (>= 1.0.0)
Expand Down Expand Up @@ -194,11 +194,11 @@ GEM
coffee-script-source
execjs
coffee-script-source (1.12.2)
concurrent-ruby (1.2.2)
concurrent-ruby (1.3.4)
connection_pool (2.4.1)
crass (1.0.6)
daemons (1.4.1)
date (3.3.4)
date (3.4.1)
declarative (0.0.20)
deprecation (0.99.0)
activesupport
Expand All @@ -224,7 +224,7 @@ GEM
encryptor (3.0.0)
equivalent-xml (0.6.0)
nokogiri (>= 1.4.3)
erubi (1.12.0)
erubi (1.13.1)
execjs (2.9.1)
factory_bot (4.11.1)
activesupport (>= 3.0.0)
Expand Down Expand Up @@ -287,7 +287,7 @@ GEM
http-cookie (1.0.5)
domain_name (~> 0.5)
httpclient (2.8.3)
i18n (1.14.1)
i18n (1.14.6)
concurrent-ruby (~> 1.0)
iso-639 (0.3.6)
jaro_winkler (1.5.6)
Expand Down Expand Up @@ -331,15 +331,15 @@ GEM
net-imap
net-pop
net-smtp
marcel (1.0.2)
marcel (1.0.4)
matrix (0.4.2)
method_source (1.0.0)
method_source (1.1.0)
mime-types (3.5.1)
mime-types-data (~> 3.2015)
mime-types-data (3.2023.1205)
mini_mime (1.1.5)
mini_portile2 (2.8.5)
minitest (5.20.0)
mini_portile2 (2.8.8)
minitest (5.25.4)
mods (3.0.4)
edtf (~> 3.0)
iso-639
Expand All @@ -355,7 +355,7 @@ GEM
net-http (0.4.0)
uri
net-http-persistent (2.9.4)
net-imap (0.4.9)
net-imap (0.4.18)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -364,13 +364,13 @@ GEM
timeout
net-scp (4.0.0)
net-ssh (>= 2.6.5, < 8.0.0)
net-smtp (0.4.0)
net-smtp (0.5.0)
net-protocol
net-ssh (7.2.1)
netrc (0.11.0)
nio4r (2.7.0)
nio4r (2.7.4)
noid (0.9.0)
nokogiri (1.15.5)
nokogiri (1.15.7)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
nom-xml (1.2.0)
Expand All @@ -391,28 +391,28 @@ GEM
public_suffix (5.1.1)
puma (6.5.0)
nio4r (~> 2.0)
racc (1.7.3)
racc (1.8.1)
rack (2.2.10)
rack-protection (3.1.0)
rack (~> 2.2, >= 2.2.4)
rack-proxy (0.7.7)
rack
rack-test (2.1.0)
rack-test (2.2.0)
rack (>= 1.3)
rails (6.1.7.6)
actioncable (= 6.1.7.6)
actionmailbox (= 6.1.7.6)
actionmailer (= 6.1.7.6)
actionpack (= 6.1.7.6)
actiontext (= 6.1.7.6)
actionview (= 6.1.7.6)
activejob (= 6.1.7.6)
activemodel (= 6.1.7.6)
activerecord (= 6.1.7.6)
activestorage (= 6.1.7.6)
activesupport (= 6.1.7.6)
rails (6.1.7.10)
actioncable (= 6.1.7.10)
actionmailbox (= 6.1.7.10)
actionmailer (= 6.1.7.10)
actionpack (= 6.1.7.10)
actiontext (= 6.1.7.10)
actionview (= 6.1.7.10)
activejob (= 6.1.7.10)
activemodel (= 6.1.7.10)
activerecord (= 6.1.7.10)
activestorage (= 6.1.7.10)
activesupport (= 6.1.7.10)
bundler (>= 1.15.0)
railties (= 6.1.7.6)
railties (= 6.1.7.10)
sprockets-rails (>= 2.0.0)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
Expand All @@ -424,14 +424,14 @@ GEM
nokogiri (>= 1.6)
rails-html-sanitizer (1.5.0)
loofah (~> 2.19, >= 2.19.1)
railties (6.1.7.6)
actionpack (= 6.1.7.6)
activesupport (= 6.1.7.6)
railties (6.1.7.10)
actionpack (= 6.1.7.10)
activesupport (= 6.1.7.10)
method_source
rake (>= 12.2)
thor (~> 1.0)
rainbow (3.1.1)
rake (13.1.0)
rake (13.2.1)
random-word (2.1.1)
rb-fsevent (0.11.2)
rb-inotify (0.10.1)
Expand Down Expand Up @@ -573,9 +573,9 @@ GEM
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
sprockets-rails (3.4.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
sprockets-rails (3.5.2)
actionpack (>= 6.1)
activesupport (>= 6.1)
sprockets (>= 3.0.0)
sqlite3 (1.6.9)
mini_portile2 (~> 2.8.0)
Expand All @@ -587,10 +587,10 @@ GEM
temple (0.10.3)
terser (1.1.20)
execjs (>= 0.3.0, < 3)
thor (1.3.0)
thor (1.3.2)
thread (0.2.2)
tilt (2.3.0)
timeout (0.4.1)
timeout (0.4.3)
trailblazer-option (0.1.2)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
Expand Down Expand Up @@ -626,7 +626,7 @@ GEM
rexml
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.12)
zeitwerk (2.6.18)

PLATFORMS
ruby
Expand Down
1 change: 1 addition & 0 deletions app/jobs/export_search_results_to_csv_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class ExportSearchResultsToCsvJob < ActiveJob::Base
queue_as Hyacinth::Queue::DIGITAL_OBJECT_CSV_EXPORT

def perform(csv_export_id)
Rails.logger.error "1233333 ExportSearchResultsToCsvJob is running!!!!!!!!!!!!"
start_time = Time.now

csv_export = CsvExport.find(csv_export_id)
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/process_digital_object_import_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def find_or_create_digital_object(digital_object_data, user, digital_object_impo
# digital_object_import instance because when it's called, we can't guarantee
# that we were able to successfully obtain a digital_object_import instance.
# We try multiple times, within this method, to obtain an instance.
def handle_unexpected_processing_error(digital_object_import_id, e, queue_long_jobs = HYACINTH[:queue_long_jobs])
def handle_unexpected_processing_error(digital_object_import_id, e)
# In the case of some unexpected, otherwise unhandled error, mark this job
# as a failure so that it doesn't get stuck as pending forever, causing
# other jobs that depend on it to be requeued forever.
Expand Down
7 changes: 4 additions & 3 deletions app/models/concerns/digital_object/persistence.rb
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ def persist_parent_changes
# validation. This will delete a record without updating other records that reference it (i.e. child records).
# NOTE: This method does NOT delete files on the filesystem.
def destroy(purge = false, force = false)
result = false
@db_record.with_lock do
# Set state of 'D' for this object, which means "deleted" in Fedora
self.state = 'D'
Expand All @@ -160,7 +161,7 @@ def destroy(purge = false, force = false)
# Delete db record
@db_record.destroy

return true
result = true
else
if @parent_digital_object_pids.present?
# If present, convert this DigitalObject's parent membership relationships to obsolete parent relationships (for future auditing/troubleshooting purposes)
Expand All @@ -170,14 +171,14 @@ def destroy(purge = false, force = false)
end
end

return save
result = save
end
else
Hyacinth::Utils::Logger.logger.error "Tried to delete Hyacinth record with pid #{pid}, but record was not valid. Errors: #{errors.messages.inspect}"
end
end

false
result
end

# Note: purge method is not currently implemented. If implemented some day, this would completely delete all traces of an object from Fedora.
Expand Down
36 changes: 12 additions & 24 deletions lib/hyacinth/queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,25 @@ def self.process_digital_object_import(digital_object_import)
digital_object_import_id = digital_object_import.id
priority = digital_object_import.import_job.priority.to_sym

if HYACINTH[:queue_long_jobs]
case priority
when :low
queue_name = Hyacinth::Queue::DIGITAL_OBJECT_IMPORT_LOW
when :medium
queue_name = Hyacinth::Queue::DIGITAL_OBJECT_IMPORT_MEDIUM
when :high
queue_name = Hyacinth::Queue::DIGITAL_OBJECT_IMPORT_HIGH
else
raise 'Invalid priority: ' + priority.inspect
end

ProcessDigitalObjectImportJob.set(queue: queue_name).perform_later(digital_object_import_id)
case priority
when :low
queue_name = Hyacinth::Queue::DIGITAL_OBJECT_IMPORT_LOW
when :medium
queue_name = Hyacinth::Queue::DIGITAL_OBJECT_IMPORT_MEDIUM
when :high
queue_name = Hyacinth::Queue::DIGITAL_OBJECT_IMPORT_HIGH
else
ProcessDigitalObjectImportJob.perform_now(digital_object_import_id)
raise 'Invalid priority: ' + priority.inspect
end

ProcessDigitalObjectImportJob.set(queue: queue_name).perform_later(digital_object_import_id)
end

def self.export_search_results_to_csv(csv_export_id)
if HYACINTH[:queue_long_jobs]
ExportSearchResultsToCsvJob.perform_later(csv_export_id)
else
ExportSearchResultsToCsvJob.perform_now(csv_export_id)
end
ExportSearchResultsToCsvJob.perform_later(csv_export_id)
end

def self.reindex_digital_object(digital_object_pid)
if HYACINTH[:queue_long_jobs]
ReindexDigitalObjectJob.perform_later(digital_object_pid)
else
ReindexDigitalObjectJob.perform_now(digital_object_pid)
end
ReindexDigitalObjectJob.perform_later(digital_object_pid)
end
end
Loading

0 comments on commit 65351d7

Please sign in to comment.