mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Revert all PHP-Based MySQL Locks introduced in #1584
This commit is contained in:
@@ -105,19 +105,8 @@ if ($config['distributed_poller'] === true) {
|
|||||||
$where .= ' AND poller_group IN('.$config['distributed_poller_group'].')';
|
$where .= ' AND poller_group IN('.$config['distributed_poller_group'].')';
|
||||||
}
|
}
|
||||||
|
|
||||||
echo 'Checking for MySQL Locks:';
|
|
||||||
while (!dbCheckLock('schema_update')) {
|
|
||||||
echo '.';
|
|
||||||
sleep(1);
|
|
||||||
}
|
|
||||||
echo PHP_EOL;
|
|
||||||
|
|
||||||
foreach (dbFetch("SELECT * FROM `devices` WHERE status = 1 AND disabled = 0 $where ORDER BY device_id DESC") as $device) {
|
foreach (dbFetch("SELECT * FROM `devices` WHERE status = 1 AND disabled = 0 $where ORDER BY device_id DESC") as $device) {
|
||||||
if (dbGetLock('discovering.' . $device['device_id'])) {
|
discover_device($device, $options);
|
||||||
register_shutdown_function('dbReleaseLock','discovering.'.$device['device_id']);
|
|
||||||
discover_device($device, $options);
|
|
||||||
dbReleaseLock('discovering.' . $device['device_id']);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$end = utime();
|
$end = utime();
|
||||||
|
@@ -59,36 +59,6 @@ function dbQuery($sql, $parameters=array()) {
|
|||||||
}//end dbQuery()
|
}//end dbQuery()
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Aquire a lock on a string
|
|
||||||
* */
|
|
||||||
function dbGetLock($data, $timeout = 0) {
|
|
||||||
$sql = 'SELECT GET_LOCK(\'' . $data . '\',' . $timeout . ')';
|
|
||||||
$result = dbFetchCell($sql);
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check a lock on a string
|
|
||||||
* */
|
|
||||||
function dbCheckLock($data) {
|
|
||||||
$sql = 'SELECT IS_FREE_LOCK(\'' . $data . '\')';
|
|
||||||
$result = dbFetchCell($sql);
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Release a lock on a string
|
|
||||||
* */
|
|
||||||
function dbReleaseLock($data) {
|
|
||||||
$sql = 'SELECT RELEASE_LOCK(\'' . $data . '\')';
|
|
||||||
$result = dbFetchCell($sql);
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Passed an array and a table name, it attempts to insert the data into the table.
|
* Passed an array and a table name, it attempts to insert the data into the table.
|
||||||
* Check for boolean false to determine whether insert failed
|
* Check for boolean false to determine whether insert failed
|
||||||
|
@@ -59,35 +59,6 @@ function dbQuery($sql, $parameters=array()) {
|
|||||||
}//end dbQuery()
|
}//end dbQuery()
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Aquire a lock on a string
|
|
||||||
* */
|
|
||||||
function dbGetLock($data, $timeout = 0) {
|
|
||||||
$sql = 'SELECT GET_LOCK(\'' . $data . '\',' . $timeout . ')';
|
|
||||||
$result = dbFetchCell($sql);
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Check a lock on a string
|
|
||||||
* */
|
|
||||||
function dbCheckLock($data) {
|
|
||||||
$sql = 'SELECT IS_FREE_LOCK(\'' . $data . '\')';
|
|
||||||
$result = dbFetchCell($sql);
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Release a lock on a string
|
|
||||||
* */
|
|
||||||
function dbReleaseLock($data) {
|
|
||||||
$sql = 'SELECT RELEASE_LOCK(\'' . $data . '\')';
|
|
||||||
$result = dbFetchCell($sql);
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Passed an array and a table name, it attempts to insert the data into the table.
|
* Passed an array and a table name, it attempts to insert the data into the table.
|
||||||
* Check for boolean false to determine whether insert failed
|
* Check for boolean false to determine whether insert failed
|
||||||
|
@@ -91,13 +91,6 @@ if ($tmp[0] <= $db_rev) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!dbGetLock('schema_update')) {
|
|
||||||
echo "Schema update already in progress. Exiting\n";
|
|
||||||
exit(1);
|
|
||||||
} //end if
|
|
||||||
|
|
||||||
register_shutdown_function('dbReleaseLock','schema_update');
|
|
||||||
|
|
||||||
foreach ($filelist as $file) {
|
foreach ($filelist as $file) {
|
||||||
list($filename,$extension) = explode('.', $file, 2);
|
list($filename,$extension) = explode('.', $file, 2);
|
||||||
if ($filename > $db_rev) {
|
if ($filename > $db_rev) {
|
||||||
@@ -168,4 +161,3 @@ if ($updating) {
|
|||||||
echo "-- Done\n";
|
echo "-- Done\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
dbReleaseLock('schema_update');
|
|
||||||
|
17
poller.php
17
poller.php
@@ -100,13 +100,6 @@ if (isset($options['r'])) {
|
|||||||
$config['norrd'] = true;
|
$config['norrd'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo 'Checking for MySQL Locks:';
|
|
||||||
while (!dbCheckLock('schema_update')) {
|
|
||||||
echo '.';
|
|
||||||
sleep(1);
|
|
||||||
}
|
|
||||||
echo PHP_EOL;
|
|
||||||
|
|
||||||
rrdtool_pipe_open($rrd_process, $rrd_pipes);
|
rrdtool_pipe_open($rrd_process, $rrd_pipes);
|
||||||
|
|
||||||
echo "Starting polling run:\n\n";
|
echo "Starting polling run:\n\n";
|
||||||
@@ -117,13 +110,9 @@ if (!isset($query)) {
|
|||||||
|
|
||||||
foreach (dbFetch($query) as $device) {
|
foreach (dbFetch($query) as $device) {
|
||||||
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = '".$device['device_id']."'");
|
$device = dbFetchRow("SELECT * FROM `devices` WHERE `device_id` = '".$device['device_id']."'");
|
||||||
if (dbGetLock('polling.' . $device['device_id'])) {
|
poll_device($device, $options);
|
||||||
register_shutdown_function('dbReleaseLock','polling.'.$device['device_id']);
|
RunRules($device['device_id']);
|
||||||
poll_device($device, $options);
|
echo "\r\n";
|
||||||
RunRules($device['device_id']);
|
|
||||||
echo "\r\n";
|
|
||||||
dbReleaseLock('polling.' . $device['device_id']);
|
|
||||||
}
|
|
||||||
$polled_devices++;
|
$polled_devices++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user