]> git.mxchange.org Git - friendica.git/commitdiff
Quit when processlist is too long
authorMichael Vogel <icarus@dabo.de>
Fri, 3 Jun 2016 21:10:23 +0000 (23:10 +0200)
committerMichael Vogel <icarus@dabo.de>
Fri, 3 Jun 2016 21:10:23 +0000 (23:10 +0200)
include/dbm.php
include/poller.php
index.php

index f68987c2356d23a016bfdc4a0546c0f1d25d9f37..1e1c3706e0e88949f2aca0bb4939430f2d9fa0d1 100644 (file)
@@ -15,12 +15,14 @@ class dbm {
                // updating
 
                $statelist = "";
+               $processes = 0;
                foreach ($states AS $state => $usage) {
                        if ($statelist != "")
                                $statelist .= ", ";
                        $statelist .= $state.": ".$usage;
+                       ++$processes;
                }
-               return($statelist);
+               return(array("list" => $statelist, "amount" => $processes));
        }
 }
 ?>
index 714d4c537c896f9ae79f2a01f6ba04d9a2c9e1ef..45dc332e1774d084d953c251a9f36a454e2629fe 100644 (file)
@@ -28,8 +28,11 @@ function poller_run(&$argv, &$argc){
        };
 
        $processlist = dbm::processlist();
-       if ($processlist != "")
-               logger("Processlist: ".$processlist, LOGGER_DEBUG);
+       if ($processlist["list"] != "") {
+               logger("Processes: ".$processlist["amount"]." - Processlist: ".$processlist["list"], LOGGER_DEBUG);
+               if ($processlist["amount"] > 5)
+                       return;
+       }
 
        if (poller_max_connections_reached())
                return;
@@ -66,8 +69,11 @@ function poller_run(&$argv, &$argc){
 
                // Log the type of database processes
                $processlist = dbm::processlist();
-               if ($processlist != "")
-                       logger("Processlist: ".$processlist, LOGGER_DEBUG);
+               if ($processlist["amount"] != "") {
+                       logger("Processes: ".$processlist["amount"]." - Processlist: ".$processlist["list"], LOGGER_DEBUG);
+                       if ($processlist["amount"] > 5)
+                               return;
+               }
 
                // Constantly check the number of available database connections to let the frontend be accessible at any time
                if (poller_max_connections_reached())
index ec72771341807bbd56260dd92887d4cd85470df8..a25c6dc77602aa05dcfa1ad9e4f460d6d68f8137 100644 (file)
--- a/index.php
+++ b/index.php
@@ -55,8 +55,14 @@ if(!$install) {
        load_config('system');
 
        $processlist = dbm::processlist();
-       if ($processlist != "")
-               logger("Processlist: ".$processlist, LOGGER_DEBUG);
+       if ($processlist["list"] != "") {
+               logger("Processes: ".$processlist["amount"]." - Processlist: ".$processlist["list"], LOGGER_DEBUG);
+
+               // More than 20 running database processes?
+               // The system is too busy, so quit.
+               if ($processlist["amount"] > 20)
+                       system_unavailable();
+       }
 
        $maxsysload_frontend = intval(get_config('system','maxloadavg_frontend'));
        if($maxsysload_frontend < 1)