From 78e4d64658985873c52481a4f5e0589723e1e6ae Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 28 Apr 2021 14:16:28 +0200 Subject: [PATCH] avoid using cache while getting/releasing a lock from DB --- pandora_console/include/db/mysql.php | 4 ++++ pandora_console/include/functions_db.php | 19 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/pandora_console/include/db/mysql.php b/pandora_console/include/db/mysql.php index 746187c00d..3368c3454b 100644 --- a/pandora_console/include/db/mysql.php +++ b/pandora_console/include/db/mysql.php @@ -391,6 +391,10 @@ function mysql_db_process_sql($sql, $rettype='affected_rows', $dbconnection='', return false; } + if (isset($config['dbcache']) === true) { + $cache = $config['dbcache']; + } + if ($cache && ! empty($sql_cache[$sql_cache['id']][$sql])) { $retval = $sql_cache[$sql_cache['id']][$sql]; $sql_cache['saved'][$sql_cache['id']]++; diff --git a/pandora_console/include/functions_db.php b/pandora_console/include/functions_db.php index 9afb82d8c0..a683be1313 100644 --- a/pandora_console/include/functions_db.php +++ b/pandora_console/include/functions_db.php @@ -2188,6 +2188,12 @@ function db_check_minor_relase_available_to_um($package, $ent, $offline) */ function db_get_lock($lockname, $expiration_time=86400) { + global $config; + + // Temporary disable to get a valid lock if any... + $cache = $config['dbcache']; + $config['dbcache'] = false; + $lock_status = db_get_value_sql( sprintf( 'SELECT IS_FREE_LOCK("%s")', @@ -2204,9 +2210,11 @@ function db_get_lock($lockname, $expiration_time=86400) ) ); + $config['dbcache'] = $cache; return $lock_status; } + $config['dbcache'] = $cache; return 0; } @@ -2222,12 +2230,21 @@ function db_get_lock($lockname, $expiration_time=86400) */ function db_release_lock($lockname) { - return db_get_value_sql( + global $config; + $cache = $config['dbcache']; + $config['dbcache'] = false; + + $return = db_get_value_sql( sprintf( 'SELECT RELEASE_LOCK("%s")', $lockname ) ); + + $config['dbcache'] = $cache; + + return $return; + }