1
1
Fork 0

Merge pull request #2742 from annando/1608-priority-rearranges

New priority level for stale processes
This commit is contained in:
Tobias Diekershoff 2016-08-19 07:19:32 +02:00 committed by GitHub
commit 9fa4a3bac6
2 changed files with 13 additions and 13 deletions

View file

@ -392,11 +392,12 @@ define ( 'GRAVITY_COMMENT', 6);
* Process priority for the worker
* @{
*/
define('PRIORITY_UNDEFINED', 0);
define('PRIORITY_SYSTEM', 10);
define('PRIORITY_HIGH', 20);
define('PRIORITY_MEDIUM', 30);
define('PRIORITY_LOW', 40);
define('PRIORITY_UNDEFINED', 0);
define('PRIORITY_CRITICAL', 10);
define('PRIORITY_HIGH', 20);
define('PRIORITY_MEDIUM', 30);
define('PRIORITY_LOW', 40);
define('PRIORITY_NEGLIGIBLE',50);
/* @}*/
@ -1410,7 +1411,7 @@ function check_db() {
$build = DB_UPDATE_VERSION;
}
if($build != DB_UPDATE_VERSION)
proc_run(PRIORITY_SYSTEM, 'include/dbupdate.php');
proc_run(PRIORITY_CRITICAL, 'include/dbupdate.php');
}

View file

@ -232,11 +232,11 @@ function poller_kill_stale_workers() {
// Kill long running processes
// Check if the priority is in a valid range
if (!in_array($pid["priority"], array(PRIORITY_SYSTEM, PRIORITY_HIGH, PRIORITY_MEDIUM, PRIORITY_LOW)))
if (!in_array($pid["priority"], array(PRIORITY_CRITICAL, PRIORITY_HIGH, PRIORITY_MEDIUM, PRIORITY_LOW, PRIORITY_NEGLIGIBLE)))
$pid["priority"] = PRIORITY_MEDIUM;
// Define the maximum durations
$max_duration_defaults = array(PRIORITY_SYSTEM => 360, PRIORITY_HIGH => 10, PRIORITY_MEDIUM => 60, PRIORITY_LOW => 180);
$max_duration_defaults = array(PRIORITY_CRITICAL => 360, PRIORITY_HIGH => 10, PRIORITY_MEDIUM => 60, PRIORITY_LOW => 180, PRIORITY_NEGLIGIBLE => 360);
$max_duration = $max_duration_defaults[$pid["priority"]];
$argv = json_decode($pid["parameter"]);
@ -254,7 +254,7 @@ function poller_kill_stale_workers() {
q("UPDATE `workerqueue` SET `executed` = '0000-00-00 00:00:00', `created` = '%s',
`priority` = %d, `pid` = 0 WHERE `pid` = %d",
dbesc(datetime_convert()),
intval(PRIORITY_LOW),
intval(PRIORITY_NEGLIGIBLE),
intval($pid["pid"]));
} else
logger("Worker process ".$pid["pid"]." (".implode(" ", $argv).") now runs for ".round($duration)." of ".$max_duration." allowed minutes. That's okay.", LOGGER_DEBUG);
@ -294,12 +294,11 @@ function poller_too_much_workers() {
$s = q("SELECT `priority` FROM `workerqueue` WHERE `executed` = '0000-00-00 00:00:00' ORDER BY `priority` LIMIT 1");
$top_priority = $s[0]["priority"];
$s = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE `priority` <= %d AND `executed` != '0000-00-00 00:00:00'",
$s = q("SELECT `id` FROM `workerqueue` WHERE `priority` <= %d AND `executed` != '0000-00-00 00:00:00' LIMIT 1",
intval($top_priority));
$high_running = $s[0]["total"];
$high_running = dbm::is_result($s);
/// @todo define maximum number of fastlanes
if (($high_running == 0) AND ($top_priority != PRIORITY_UNDEFINED) AND ($top_priority < PRIORITY_LOW)) {
if (!$high_running AND ($top_priority > PRIORITY_UNDEFINED) AND ($top_priority < PRIORITY_NEGLIGIBLE)) {
logger("There are jobs with priority ".$top_priority." waiting but none is executed. Open a fastlane.", LOGGER_DEBUG);
$queues = $active + 1;
}