Reschedule killed processes at the beginning of the queue.

This commit is contained in:
Michael Vogel 2016-08-04 15:33:15 +02:00
parent dad74e9650
commit 074ae59f49
1 changed files with 4 additions and 3 deletions

View File

@ -235,9 +235,10 @@ function poller_kill_stale_workers() {
logger("Worker process ".$pid["pid"]." took more than 3 hours. It will be killed now."); logger("Worker process ".$pid["pid"]." took more than 3 hours. It will be killed now.");
posix_kill($pid["pid"], SIGTERM); posix_kill($pid["pid"], SIGTERM);
// Question: If a process is stale: Should we remove it or should we reschedule it? // We killed the stale process.
// By now we rescheduling it. It's maybe not the wisest decision? // To avoid a blocking situation we reschedule the process at the beginning of the queue.
q("UPDATE `workerqueue` SET `executed` = '0000-00-00 00:00:00', `pid` = 0 WHERE `pid` = %d", q("UPDATE `workerqueue` SET `executed` = '0000-00-00 00:00:00', `created` = '%s', `pid` = 0 WHERE `pid` = %d",
dbesc(datetime_convert()),
intval($pid["pid"])); intval($pid["pid"]));
} else } else
logger("Worker process ".$pid["pid"]." now runs for ".round($duration)." minutes. That's okay.", LOGGER_DEBUG); logger("Worker process ".$pid["pid"]." now runs for ".round($duration)." minutes. That's okay.", LOGGER_DEBUG);