08ec45443d
Dear instances, make sure to update your sidekiq processes. Indead, we are adopting a new strategy for daemons that process our background jobs. Now their is only 3 queues on sidekiq (still, we keep archive/export on delayed job for now). The big idea : allow any worker to deal with any queue (capacity mgmt) : - critical: must be procesed now - default: will be processed asap - low: do it after everything else FYI: we had 50% of our server capacity on reserved queues. Leading to bottle neck processing (reserved queues/worker not processing other queues). We HAD TO fix it. Sorry for the inconvenience TBH, this is an idea of Colin Darie <colin@darie.eu>. I'm just pushing it forward. Co-Authored-By: Colin Darie <colin@darie.eu>
23 lines
720 B
Ruby
23 lines
720 B
Ruby
# frozen_string_literal: true
|
|
|
|
class BatchOperationProcessOneJob < ApplicationJob
|
|
queue_as :critical
|
|
retry_on StandardError, attempts: 1 # default 5, for now no retryable behavior
|
|
|
|
def perform(batch_operation, dossier)
|
|
dossier = batch_operation.dossiers_safe_scope.find(dossier.id)
|
|
begin
|
|
ActiveRecord::Base.transaction do
|
|
batch_operation.process_one(dossier)
|
|
batch_operation.track_processed_dossier(true, dossier)
|
|
end
|
|
rescue => error
|
|
ActiveRecord::Base.transaction do
|
|
batch_operation.track_processed_dossier(false, dossier)
|
|
end
|
|
raise error
|
|
end
|
|
rescue ActiveRecord::RecordNotFound
|
|
dossier.update_column(:batch_operation_id, nil)
|
|
end
|
|
end
|