Pages: 1 2
Since upgrading to 15.4.0, I'm getting a lot of "an error has occurred" red messages on photos when saving changes in single mode in batch manager. I have to make a small change (like put a space in description and then delete) so I can attempt the save again and then it typically works. What would suddenly be causing this?
Not sure if this is related, but in the log I'm seeing stuff like this:
[2025-02-25 20:30:47] [DEBUG] $images_to_update
0: 75618
[2025-02-25 20:30:50] [INFO] [getuserdata][exec_code=3dd1][user_id=1] needs user_cache to be rebuilt
[2025-02-25 20:30:50] [INFO] [generate_user_cache-u1][exec=6ed4a895] starts now
[2025-02-25 20:30:50] [INFO] [generate_user_cache-u1][exec=6ed4a895] wins the race and gets the token!
[2025-02-25 20:30:50] [INFO] [getuserdata][exec_code=3dd1][user_id=1] user_cache generated, executed in 0.600 s
[2025-02-25 20:30:50] [DEBUG] taglist_before
75619: array(
0 => '4372',
1 => '4556',
2 => '4559',
3 => '4560',
4 => '4561',
5 => '4973',
6 => '34648',
7 => '35569',
8 => '36405',
)
[2025-02-25 20:30:50] [DEBUG] taglist_after
75619: array(
0 => '4372',
1 => '4556',
2 => '4559',
3 => '4560',
4 => '4561',
5 => '4973',
6 => '34648',
7 => '35569',
8 => '36405',
9 => '37805',
)Any suggestions?
Offline

Offline
Hello,
Exactly the same problem after upgrade to 15.4.0
Alexandr
Offline
I'm not seeing the problem in global mode of batch manager, just single mode.
And in case it matters, I typically use the 10-photos-per-page setting in single mode. If I get a chance I'll test with 5-photos-per-page.
Offline
I can't reproduce for now and we have another equivalent report (in the French forum).
Can you use your web browser console to see if you have any specific response for the call to ws.php ?
Offline
windracer wrote:
I'm not seeing the problem in global mode of batch manager, just single mode.
And in case it matters, I typically use the 10-photos-per-page setting in single mode. If I get a chance I'll test with 5-photos-per-page.
I usually use 5-photos-per-page setting. But, if I actually have just only one photo to edit in a single mode, there is no error.
Offline
plg wrote:
I can't reproduce for now and we have another equivalent report (in the French forum).
Can you use your web browser console to see if you have any specific response for the call to ws.php ?
https://sandbox.piwigo.com/i?/uploads/4 … ead-la.png
When I edit some existing photos in a single mode, everything is ok.
From web browser console:
{"stat":"ok","result":null}
Maybe there is an issue only while editing just uploaded photos? I will try.
Offline
Seeing 503 errors from ws.php:
Offline
I have been able to reproduce the bug. I need you to try this solution. Open file include/functions.inc.php, about line 2881, just before function pwg_unique_exec_ends, insert this new function:
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;
}then in include/functions_user.inc.php, line 445, before :
else
{
$logger->info($logger_msg.'user_cache not ready yet, after waiting ....insert
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 '.get_elapsed_time($user_cache_waiting_start_time, get_moment()));
return getuserdata($user_id, true);
}I have other solutions (and I will certainly combine several to get the optimal solution) but I would like you to test only this one for now.
Offline
abravorus wrote:
I usually use 5-photos-per-page setting. But, if I actually have just only one photo to edit in a single mode, there is no error.
There are several problems and the new "avoid too many user_cache rebuilt" system in Piwigo 15.4.0 has made them more obvious:
* the batch manager unit mode launches all pwg.images.setInfo at once, instead of one by one
* when calling pwg.images.setInfo Piwigo rebuilds the user_cache (which is not necessary)
* pwg.images.setInfo resets the cache, whatever you change on the photo, even just the title (which is not necessary)
So if you have 5 concurrent requests all needing the user_cache and all reseting the user_cache, you get into a conflict. Fixes are coming.
Of course, if you edit only one photo in the batch manager unit mode, not concurrent requests, no conflict.
Offline
plg wrote:
I have been able to reproduce the bug. I need you to try this solution. Open file include/functions.inc.php, about line 2881, just before function pwg_unique_exec_ends, insert this new function:
You say "just before function pwg_unique_exec_ends" but you don't mean to put the new function block inside the pwg_unique_exec_ends, right? It should be its own function, like this?
function pwg_unique_exec_ends($token_name)
{
conf_delete_param($token_name.'_running');
}
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;
}
?>Because after making the change, I am getting the "an error has occurred" on every item in single mode immediately, so I clearly messed something up.
Offline
Glad to hear a fix is coming, I recently changed my hosting configuration and was assuming this was a glitch in my setup.
Thanks for the public sharing of the info!
Offline
windracer wrote:
You say "just before function pwg_unique_exec_ends" but you don't mean to put the new function block inside the pwg_unique_exec_ends, right? It should be its own function, like this?
Yes of course, you don't write a function inside a function (actually you can, but don't)
For me it works, it's just that it needs to rebuild user_cache as many times as image to save. For example, if my user_cache takes 5 seconds to rebuilt, one image will take 5s+epsilon, another image will take 2x5s+epsilon and the third photo will take 3x5s+epsilon. No guarantee that the first image in the list will finish first. At this point, the order is random. The total time to perform will be the slowest image, ie 15seconds+epsilon.
We're working on:
* do not send calls to pwg.images.setInfo in parallel, but one by one. First photo would take 5s+epsilon. The total time would be 3x(5s+epsilon). Not better in time, but avoid deadlock on mutual exclusion.
* avoiding to rebuild user_cache. The total time will be 3xepsilon. Much better.
* avoiding to reset user_cache when not necessary. Nice but a bit dangerous.
Offline
Another solution which completely solve the speed problem and avoid any "an error has occured". In file include/user.inc.php, replace:
$user = build_user( $user['id'],
( defined('IN_ADMIN') and IN_ADMIN ) ? false : true // use cache ?
);by
$page['user_use_cache'] = true;
if (defined('IN_ADMIN') and IN_ADMIN)
{
$page['user_use_cache'] = false;
}
elseif (
isset($_REQUEST['method'])
and 'pwg.images.setInfo' == $_REQUEST['method']
and isset($_SERVER['HTTP_REFERER'])
and preg_match('/\/admin\.php\?page=/', $_SERVER['HTTP_REFERER'])
)
{
$page['user_use_cache'] = false;
}
$user = build_user( $user['id'], $page['user_use_cache']);Offline
I figured out my issue (I had some other problems in my test site) and that second code recommendation (in user.inc.php) seems to fix the problem for me.
Offline
Pages: 1 2