mirror of
https://github.com/friendica/friendica
synced 2025-04-26 03:50:12 +00:00
Merge remote-tracking branch 'upstream/3.5.2rc' into 1705-dbclean-advanced
This commit is contained in:
commit
c9ea18ce74
14 changed files with 34042 additions and 33704 deletions
|
@ -8,6 +8,10 @@ require_once("include/text.php");
|
|||
|
||||
define('NEW_UPDATE_ROUTINE_VERSION', 1170);
|
||||
|
||||
const DB_UPDATE_NOT_CHECKED = 0; // Database check wasn't executed before
|
||||
const DB_UPDATE_SUCCESSFUL = 1; // Database check was successful
|
||||
const DB_UPDATE_FAILED = 2; // Database check failed
|
||||
|
||||
/*
|
||||
* Converts all tables from MyISAM to InnoDB
|
||||
*/
|
||||
|
@ -480,6 +484,12 @@ function update_structure($verbose, $action, $tables=null, $definition=null) {
|
|||
Config::set('system', 'maintenance_reason', '');
|
||||
}
|
||||
|
||||
if ($errors) {
|
||||
Config::set('system', 'dbupdate', DB_UPDATE_FAILED);
|
||||
} else {
|
||||
Config::set('system', 'dbupdate', DB_UPDATE_SUCCESSFUL);
|
||||
}
|
||||
|
||||
return $errors;
|
||||
}
|
||||
|
||||
|
|
|
@ -417,11 +417,9 @@ function poller_too_much_workers() {
|
|||
|
||||
$maxqueues = $queues;
|
||||
|
||||
$active = poller_active_workers();
|
||||
|
||||
// Decrease the number of workers at higher load
|
||||
$load = current_load();
|
||||
if($load) {
|
||||
if ($load) {
|
||||
$maxsysload = intval(Config::get("system", "maxloadavg", 50));
|
||||
|
||||
$maxworkers = $queues;
|
||||
|
@ -431,6 +429,33 @@ function poller_too_much_workers() {
|
|||
$slope = $maxworkers / pow($maxsysload, $exponent);
|
||||
$queues = ceil($slope * pow(max(0, $maxsysload - $load), $exponent));
|
||||
|
||||
$active = 0;
|
||||
|
||||
// Create a list of queue entries grouped by their priority
|
||||
$listitem = array();
|
||||
|
||||
// Adding all processes with no workerqueue entry
|
||||
$processes = dba::p("SELECT COUNT(*) AS `running` FROM `process` WHERE NOT EXISTS (SELECT id FROM `workerqueue` WHERE `workerqueue`.`pid` = `process`.`pid`)");
|
||||
if ($process = dba::fetch($processes)) {
|
||||
$listitem[0] = "0:".$process["running"];
|
||||
$active += $process["running"];
|
||||
}
|
||||
dba::close($processes);
|
||||
|
||||
// Now adding all processes with workerqueue entries
|
||||
$entries = dba::p("SELECT COUNT(*) AS `entries`, `priority` FROM `workerqueue` GROUP BY `priority`");
|
||||
while ($entry = dba::fetch($entries)) {
|
||||
$processes = dba::p("SELECT COUNT(*) AS `running` FROM `process` LEFT JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid` WHERE `priority` = ?", $entry["priority"]);
|
||||
if ($process = dba::fetch($processes)) {
|
||||
$listitem[$entry["priority"]] = $entry["priority"].":".$process["running"]."/".$entry["entries"];
|
||||
$active += $process["running"];
|
||||
}
|
||||
dba::close($processes);
|
||||
}
|
||||
dba::close($entries);
|
||||
|
||||
$processlist = implode(', ', $listitem);
|
||||
|
||||
$s = q("SELECT COUNT(*) AS `total` FROM `workerqueue` WHERE `executed` <= '%s'", dbesc(NULL_DATE));
|
||||
$entries = $s[0]["total"];
|
||||
|
||||
|
@ -448,27 +473,6 @@ function poller_too_much_workers() {
|
|||
}
|
||||
}
|
||||
|
||||
// Create a list of queue entries grouped by their priority
|
||||
$running = array(PRIORITY_CRITICAL => 0,
|
||||
PRIORITY_HIGH => 0,
|
||||
PRIORITY_MEDIUM => 0,
|
||||
PRIORITY_LOW => 0,
|
||||
PRIORITY_NEGLIGIBLE => 0);
|
||||
|
||||
$r = q("SELECT COUNT(*) AS `running`, `priority` FROM `process` INNER JOIN `workerqueue` ON `workerqueue`.`pid` = `process`.`pid` GROUP BY `priority`");
|
||||
if (dbm::is_result($r))
|
||||
foreach ($r AS $process)
|
||||
$running[$process["priority"]] = $process["running"];
|
||||
|
||||
$processlist = "";
|
||||
$r = q("SELECT COUNT(*) AS `entries`, `priority` FROM `workerqueue` GROUP BY `priority`");
|
||||
if (dbm::is_result($r))
|
||||
foreach ($r as $entry) {
|
||||
if ($processlist != "")
|
||||
$processlist .= ", ";
|
||||
$processlist .= $entry["priority"].":".$running[$entry["priority"]]."/".$entry["entries"];
|
||||
}
|
||||
|
||||
logger("Load: ".$load."/".$maxsysload." - processes: ".$active."/".$entries." (".$processlist.") - maximum: ".$queues."/".$maxqueues, LOGGER_DEBUG);
|
||||
|
||||
// Are there fewer workers running as possible? Then fork a new one.
|
||||
|
@ -478,6 +482,8 @@ function poller_too_much_workers() {
|
|||
$a = get_app();
|
||||
$a->proc_run($args);
|
||||
}
|
||||
} else {
|
||||
$active = poller_active_workers();
|
||||
}
|
||||
|
||||
return($active >= $queues);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue