mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 09:42:07 +08:00
Track error message in SchedulerStats
.
This commit is contained in:
parent
31a44a7c93
commit
1f6418f907
|
@ -17,4 +17,5 @@ end
|
|||
# live_slots_finish :integer
|
||||
# started_at :datetime not null
|
||||
# success :boolean
|
||||
# error :text
|
||||
#
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddErrorToSchedulerStats < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :scheduler_stats, :error, :text
|
||||
end
|
||||
end
|
|
@ -78,6 +78,8 @@ module Scheduler
|
|||
start = Time.now.to_f
|
||||
info = @mutex.synchronize { @manager.schedule_info(klass) }
|
||||
stat = nil
|
||||
error = nil
|
||||
|
||||
begin
|
||||
info.prev_result = "RUNNING"
|
||||
@mutex.synchronize { info.write! }
|
||||
|
@ -96,6 +98,7 @@ module Scheduler
|
|||
failed = true
|
||||
rescue => e
|
||||
Discourse.handle_job_exception(e, {message: "Running a scheduled job", job: klass})
|
||||
error = "#{e.message}: #{e.backtrace.join("\n")}"
|
||||
failed = true
|
||||
end
|
||||
duration = ((Time.now.to_f - start) * 1000).to_i
|
||||
|
@ -103,10 +106,11 @@ module Scheduler
|
|||
info.prev_result = failed ? "FAILED" : "OK"
|
||||
info.current_owner = nil
|
||||
if stat
|
||||
stat.update_columns(
|
||||
stat.update!(
|
||||
duration_ms: duration,
|
||||
live_slots_finish: GC.stat[:heap_live_slots],
|
||||
success: !failed
|
||||
success: !failed,
|
||||
error: error
|
||||
)
|
||||
end
|
||||
attempts(3) do
|
||||
|
|
Loading…
Reference in New Issue
Block a user