Merge pull request #8750 from colinux/fix-jobs
Jobs: rallonge durée max pour les exports, fix des timeouts, isole DossierRebase
This commit is contained in:
commit
bc1ade02c0
9 changed files with 26 additions and 5 deletions
|
@ -21,6 +21,10 @@ class ApplicationJob < ActiveJob::Base
|
|||
ENV.fetch("MAX_ATTEMPTS_JOBS", DEFAULT_MAX_ATTEMPTS_JOBS).to_i
|
||||
end
|
||||
|
||||
def max_run_time
|
||||
4.hours # decrease run time by default
|
||||
end
|
||||
|
||||
def request_id
|
||||
@request_id ||= Current.request_id
|
||||
end
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
class ArchiveCreationJob < ApplicationJob
|
||||
queue_as :archives
|
||||
|
||||
before_perform do |job|
|
||||
Sentry.set_tags(procedure: job.arguments.first.id)
|
||||
end
|
||||
|
||||
def max_run_time
|
||||
Archive::MAX_DUREE_GENERATION
|
||||
end
|
||||
|
||||
def perform(procedure, archive, administrateur_or_instructeur)
|
||||
archive.compute_with_safe_stale_for_purge do
|
||||
ProcedureArchiveService
|
||||
|
|
|
@ -2,6 +2,6 @@ class Cron::PurgeOldEmailEventJob < Cron::CronJob
|
|||
self.schedule_expression = "every week at 3:00"
|
||||
|
||||
def perform
|
||||
EmailEvent.outdated.destroy_all
|
||||
EmailEvent.outdated.in_batches.destroy_all
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
class DossierRebaseJob < ApplicationJob
|
||||
queue_as :low_priority # they are massively enqueued, so don't interfere with others especially antivirus
|
||||
|
||||
# If by the time the job runs the Dossier has been deleted, ignore the rebase
|
||||
discard_on ActiveRecord::RecordNotFound
|
||||
|
||||
|
|
|
@ -4,7 +4,11 @@ class ExportJob < ApplicationJob
|
|||
discard_on ActiveRecord::RecordNotFound
|
||||
|
||||
before_perform do |job|
|
||||
Sentry.set_tags(procedure_id: job.arguments.first.procedure.id)
|
||||
Sentry.set_tags(procedure: job.arguments.first.procedure.id)
|
||||
end
|
||||
|
||||
def max_run_time
|
||||
Export::MAX_DUREE_GENERATION
|
||||
end
|
||||
|
||||
def perform(export)
|
||||
|
|
|
@ -14,7 +14,7 @@ class Archive < ApplicationRecord
|
|||
include TransientModelsWithPurgeableJobConcern
|
||||
|
||||
RETENTION_DURATION = 4.days
|
||||
MAX_DUREE_GENERATION = 24.hours
|
||||
MAX_DUREE_GENERATION = 16.hours
|
||||
MAX_SIZE = 100.gigabytes
|
||||
|
||||
has_and_belongs_to_many :groupe_instructeurs
|
||||
|
|
|
@ -1352,7 +1352,6 @@ class Dossier < ApplicationRecord
|
|||
|
||||
def self.notify_draft_not_submitted
|
||||
brouillon_near_procedure_closing_date
|
||||
.includes(:user)
|
||||
.find_each do |dossier|
|
||||
DossierMailer.notify_brouillon_not_submitted(dossier).deliver_later
|
||||
end
|
||||
|
|
|
@ -10,7 +10,7 @@ class SerializerService
|
|||
|
||||
def self.dossiers(procedure)
|
||||
Sentry.with_scope do |scope|
|
||||
scope.set_tags(procedure_id: procedure.id)
|
||||
scope.set_tags(procedure: procedure.id)
|
||||
|
||||
data = execute_query('serializeDossiers', { number: procedure.id })
|
||||
data && data['demarche']['dossiers']
|
||||
|
|
4
config/initializers/delayed_job.rb
Normal file
4
config/initializers/delayed_job.rb
Normal file
|
@ -0,0 +1,4 @@
|
|||
# Set max_run_time at the highest job duration we want,
|
||||
# then at job level we'll decrease this value to a lower value
|
||||
# except for ExportJob.
|
||||
Delayed::Worker.max_run_time = 16.hours # same as Export::MAX_DUREE_GENERATION but we can't yet use this constant here
|
Loading…
Add table
Reference in a new issue