app/models/process/naf/runner.rb in naf-2.0.2 vs app/models/process/naf/runner.rb in naf-2.0.3
- old
+ new
@@ -74,10 +74,11 @@
end
machine.lock_for_runner_use
begin
cleanup_old_processes
+ remove_invalid_running_jobs
wind_down_runners
# Create a machine runner, if it doesn't exist
machine_runner = ::Naf::MachineRunner.
find_or_create_by_machine_id_and_runner_cwd(machine_id: machine.id,
@@ -98,10 +99,18 @@
@current_invocation.save!
cleanup_old_processes
end
end
+ def remove_invalid_running_jobs
+ ::Naf::RunningJob.
+ joins("INNER JOIN #{Naf.schema_name}.historical_jobs AS hj ON hj.id = #{Naf.schema_name}.running_jobs.id").
+ where('finished_at IS NOT NULL AND hj.started_on_machine_id = ?', @machine.id).readonly(false).each do |job|
+ job.delete
+ end
+ end
+
def check_gc_configurations
unless @disable_gc_modifications
# These configuration changes will help forked processes, not the runner
ENV['RUBY_HEAP_MIN_SLOTS'] = '500000'
ENV['RUBY_HEAP_SLOTS_INCREMENT'] = '250000'
@@ -587,10 +596,10 @@
return send_signal_and_maybe_clean_up(job, 0)
end
def assigned_jobs(record)
if record.kind_of? ::Naf::MachineRunnerInvocation
- return ::Naf::RunningJob.started_on_invocation(record.id).select do |job|
+ return ::Naf::RunningJob.started_on_invocation(record.id).readonly(false).select do |job|
is_job_process_alive?(job)
end
else
return ::Naf::RunningJob.assigned_jobs(record).select do |job|
is_job_process_alive?(job)