add the good retry_on StaleObjectError
This commit is contained in:
parent
475bf0bd2d
commit
9ee9389ba1
2 changed files with 2 additions and 9 deletions
|
@ -1,15 +1,8 @@
|
||||||
class VirusScannerJob < ApplicationJob
|
class VirusScannerJob < ApplicationJob
|
||||||
class FileNotAnalyzedYetError < StandardError
|
|
||||||
end
|
|
||||||
|
|
||||||
queue_as :active_storage_analysis
|
|
||||||
|
|
||||||
# If by the time the job runs the blob has been deleted, ignore the error
|
# If by the time the job runs the blob has been deleted, ignore the error
|
||||||
discard_on ActiveRecord::RecordNotFound
|
discard_on ActiveRecord::RecordNotFound
|
||||||
# If the file is deleted during the scan, ignore the error
|
# If the file is deleted during the scan, ignore the error
|
||||||
discard_on ActiveStorage::FileNotFoundError
|
discard_on ActiveStorage::FileNotFoundError
|
||||||
# If the file is not analyzed yet, retry later (to avoid clobbering metadata)
|
|
||||||
retry_on FileNotAnalyzedYetError, wait: :exponentially_longer, attempts: 10
|
|
||||||
# If for some reason the file appears invalid, retry for a while
|
# If for some reason the file appears invalid, retry for a while
|
||||||
retry_on(ActiveStorage::IntegrityError, attempts: 5, wait: 5.seconds) do |job, _error|
|
retry_on(ActiveStorage::IntegrityError, attempts: 5, wait: 5.seconds) do |job, _error|
|
||||||
blob = job.arguments.first
|
blob = job.arguments.first
|
||||||
|
@ -23,7 +16,6 @@ class VirusScannerJob < ApplicationJob
|
||||||
end
|
end
|
||||||
|
|
||||||
def perform(blob)
|
def perform(blob)
|
||||||
if !blob.analyzed? then raise FileNotAnalyzedYetError end
|
|
||||||
if blob.virus_scanner.done? then return end
|
if blob.virus_scanner.done? then return end
|
||||||
|
|
||||||
metadata = extract_metadata_via_virus_scanner(blob)
|
metadata = extract_metadata_via_virus_scanner(blob)
|
||||||
|
|
|
@ -5,7 +5,8 @@ module ActiveJob::RetryOnTransientErrors
|
||||||
Excon::Error::InternalServerError,
|
Excon::Error::InternalServerError,
|
||||||
Excon::Error::GatewayTimeout,
|
Excon::Error::GatewayTimeout,
|
||||||
Excon::Error::BadRequest,
|
Excon::Error::BadRequest,
|
||||||
Excon::Error::Socket
|
Excon::Error::Socket,
|
||||||
|
ActiveRecord::StaleObjectError
|
||||||
]
|
]
|
||||||
|
|
||||||
included do
|
included do
|
||||||
|
|
Loading…
Add table
Reference in a new issue