Only kill the first stale process
This commit is contained in:
parent
bae4569a0b
commit
0ab7915810
|
@ -470,12 +470,12 @@ function poller_max_connections_reached() {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function poller_kill_stale_workers() {
|
function poller_kill_stale_workers() {
|
||||||
$entries = dba::p("SELECT `pid`, `executed`, `priority`, `parameter` FROM `workerqueue` WHERE `executed` > ? AND NOT `done` AND `pid` != 0 ORDER BY `priority`, `created`", NULL_DATE);
|
$entries = dba::p("SELECT `id`, `pid`, `executed`, `priority`, `parameter` FROM `workerqueue` WHERE `executed` > ? AND NOT `done` AND `pid` != 0 ORDER BY `priority`, `created`", NULL_DATE);
|
||||||
|
|
||||||
while ($entry = dba::fetch($entries)) {
|
while ($entry = dba::fetch($entries)) {
|
||||||
if (!posix_kill($entry["pid"], 0)) {
|
if (!posix_kill($entry["pid"], 0)) {
|
||||||
dba::update('workerqueue', array('executed' => NULL_DATE, 'pid' => 0),
|
dba::update('workerqueue', array('executed' => NULL_DATE, 'pid' => 0),
|
||||||
array('pid' => $entry["pid"], 'done' => false));
|
array('id' => $entry["id"]));
|
||||||
} else {
|
} else {
|
||||||
// Kill long running processes
|
// Kill long running processes
|
||||||
// Check if the priority is in a valid range
|
// Check if the priority is in a valid range
|
||||||
|
@ -508,7 +508,7 @@ function poller_kill_stale_workers() {
|
||||||
}
|
}
|
||||||
dba::update('workerqueue',
|
dba::update('workerqueue',
|
||||||
array('executed' => NULL_DATE, 'created' => datetime_convert(), 'priority' => $new_priority, 'pid' => 0),
|
array('executed' => NULL_DATE, 'created' => datetime_convert(), 'priority' => $new_priority, 'pid' => 0),
|
||||||
array('pid' => $entry["pid"], 'done' => false));
|
array('id' => $entry["id"]));
|
||||||
} else {
|
} else {
|
||||||
logger("Worker process ".$entry["pid"]." (".implode(" ", $argv).") now runs for ".round($duration)." of ".$max_duration." allowed minutes. That's okay.", LOGGER_DEBUG);
|
logger("Worker process ".$entry["pid"]." (".implode(" ", $argv).") now runs for ".round($duration)." of ".$max_duration." allowed minutes. That's okay.", LOGGER_DEBUG);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue