avoid using cache while getting/releasing a lock from DB

This commit is contained in:
fbsanchez 2021-04-28 14:16:28 +02:00
parent 2cd40a80fe
commit 78e4d64658
2 changed files with 22 additions and 1 deletions

View File

@ -391,6 +391,10 @@ function mysql_db_process_sql($sql, $rettype='affected_rows', $dbconnection='',
return false; return false;
} }
if (isset($config['dbcache']) === true) {
$cache = $config['dbcache'];
}
if ($cache && ! empty($sql_cache[$sql_cache['id']][$sql])) { if ($cache && ! empty($sql_cache[$sql_cache['id']][$sql])) {
$retval = $sql_cache[$sql_cache['id']][$sql]; $retval = $sql_cache[$sql_cache['id']][$sql];
$sql_cache['saved'][$sql_cache['id']]++; $sql_cache['saved'][$sql_cache['id']]++;

View File

@ -2188,6 +2188,12 @@ function db_check_minor_relase_available_to_um($package, $ent, $offline)
*/ */
function db_get_lock($lockname, $expiration_time=86400) 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( $lock_status = db_get_value_sql(
sprintf( sprintf(
'SELECT IS_FREE_LOCK("%s")', 'SELECT IS_FREE_LOCK("%s")',
@ -2204,9 +2210,11 @@ function db_get_lock($lockname, $expiration_time=86400)
) )
); );
$config['dbcache'] = $cache;
return $lock_status; return $lock_status;
} }
$config['dbcache'] = $cache;
return 0; return 0;
} }
@ -2222,12 +2230,21 @@ function db_get_lock($lockname, $expiration_time=86400)
*/ */
function db_release_lock($lockname) function db_release_lock($lockname)
{ {
return db_get_value_sql( global $config;
$cache = $config['dbcache'];
$config['dbcache'] = false;
$return = db_get_value_sql(
sprintf( sprintf(
'SELECT RELEASE_LOCK("%s")', 'SELECT RELEASE_LOCK("%s")',
$lockname $lockname
) )
); );
$config['dbcache'] = $cache;
return $return;
} }