mirror of
https://github.com/Piwigo/Piwigo.git
synced 2025-04-26 03:09:58 +03:00
fixes #2333 avoid deadlock while waiting for user_cache rebuild
This commit is contained in:
parent
6489dceadf
commit
5eacda0d76
2 changed files with 21 additions and 2 deletions
|
@ -2881,6 +2881,19 @@ INSERT IGNORE
|
|||
return $exec_id;
|
||||
}
|
||||
|
||||
function pwg_unique_exec_is_running($token_name)
|
||||
{
|
||||
$query = '
|
||||
SELECT
|
||||
COUNT(*)
|
||||
FROM '.CONFIG_TABLE.'
|
||||
WHERE param = "'.$token_name.'_running"
|
||||
;';
|
||||
list($counter) = pwg_db_fetch_row(pwg_query($query));
|
||||
|
||||
return $counter > 0;
|
||||
}
|
||||
|
||||
function pwg_unique_exec_ends($token_name)
|
||||
{
|
||||
conf_delete_param($token_name.'_running');
|
||||
|
|
|
@ -437,15 +437,21 @@ SELECT
|
|||
list($nb_cache_lines) = pwg_db_fetch_row(pwg_query($query));
|
||||
|
||||
$logger_msg = $logger_msg_prefix.'user_cache generation waiting k='.$k.' ';
|
||||
$waiting_time = get_elapsed_time($user_cache_waiting_start_time, get_moment());
|
||||
|
||||
if ($nb_cache_lines > 0)
|
||||
{
|
||||
$logger->info($logger_msg.'user_cache rebuilt, after waiting '.get_elapsed_time($user_cache_waiting_start_time, get_moment()));
|
||||
$logger->info($logger_msg.'user_cache rebuilt, after waiting '.$waiting_time);
|
||||
return getuserdata($user_id, false);
|
||||
}
|
||||
elseif (!pwg_unique_exec_is_running($cache_generation_token_name))
|
||||
{
|
||||
$logger->info($logger_msg.'user_cache rebuilt but has been reset since, give it another try, after waiting '.$waiting_time);
|
||||
return getuserdata($user_id, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
$logger->info($logger_msg.'user_cache not ready yet, after waiting '.get_elapsed_time($user_cache_waiting_start_time, get_moment()));
|
||||
$logger->info($logger_msg.'user_cache not ready yet, after waiting '.$waiting_time);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue