Refactoring: Make Scheduler more robust against job deletion while processing.

This commit is contained in:
Thorsten Eckel 2018-12-03 12:27:51 +01:00
parent 1be60c91db
commit b5a44ee0d0

View file

@ -257,13 +257,20 @@ class Scheduler < ApplicationModel
else else
_start_job(job) _start_job(job)
end end
if job.present?
job.pid = '' job.pid = ''
job.save job.save
logger.info " ...stopped thread for '#{job.method}'" logger.info " ...stopped thread for '#{job.method}'"
ActiveRecord::Base.connection.close
# release thread lock and remove thread handle # release thread lock and remove thread handle
@@jobs_started.delete(job.id) @@jobs_started.delete(job.id)
else
logger.warn ' ...Job got deleted while running'
end
ActiveRecord::Base.connection.close
end end
end end