add lock code
authorAlan <alan@roojs.com>
Wed, 3 Apr 2024 03:44:36 +0000 (11:44 +0800)
committerAlan <alan@roojs.com>
Wed, 3 Apr 2024 03:44:36 +0000 (11:44 +0800)
Pman.php

index 97b7513..3c4c119 100644 (file)
--- a/Pman.php
+++ b/Pman.php
@@ -548,9 +548,27 @@ class Pman extends HTML_FlexyFramework_Page
         
     }
     
+    /**
+     * while doing batch processes, the database sometimes get's locked up.
+     * if we are doing another batch process that can be avoided - we should just stop for a while..
+     */
     
-    
-    
+     function database_is_locked()
+    {
+        $cd = DB_DataObject::Factory('core_enum');
+        $cd->query("show processlist");
+        $cd->find();
+        $locked = 0;
+        while ($cd->fetch()) {
+            if ($cd->State == 'Waiting for table metadata lock') {
+                $locked++;
+            }
+            if ($locked>  10) {
+                return true;
+            }
+        }
+        return false;
+    }