FIX: properly log all internal job failures (#17805)

Our internal implementation of #perform on jobs performs remapping.

This happens cause we do "exception aggregation".

Scheduled jobs run on every site in the multisite cluster, and we report
one error per site that failed. During this aggregation we reshape the
context from the original object shape returned by mini_scheduler

The new integration test ensures this interface will remain stable even if
decoupled parts of the code change shapes.

Co-authored-by: Alan Guo Xiang Tan <gxtan1990@gmail.com>
This commit is contained in:
Sam
2022-08-05 17:40:22 +10:00
committed by GitHub
parent 0df1c4eab2
commit 4967541275
2 changed files with 33 additions and 1 deletions

View File

@ -177,6 +177,7 @@ module Discourse
job = context[:job]
# mini_scheduler direct reporting
if Hash === job
job_class = job["class"]
if job_class
@ -184,6 +185,11 @@ module Discourse
end
end
# internal reporting
if job.class == Class && ::Jobs::Base > job
job_exception_stats[job] += 1
end
cm = RailsMultisite::ConnectionManagement
parent_logger.handle_exception(ex, {
current_db: cm.current_db,