Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
merge r12747 from branch 2.3 to trunk
bug 2534 fixed: clean (as clean as possible with MySQL+MyISAM) handle of
concurrency on user cache refresh. No more error when regenerating several
thumbnails at once.



git-svn-id: http://piwigo.org/svn/trunk@12748 68402e56-0260-453c-a942-63ccdbb3a9ee
  • Loading branch information
plegall committed Dec 16, 2011
1 parent c92140a commit d827eac
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
6 changes: 0 additions & 6 deletions admin/batch_manager_global.php
Expand Up @@ -42,12 +42,6 @@
$form_values[$param_shortname] = $conf[$param_name];
}

// User cache must not be regenerated during simultaneous ajax requests
if (!isset($user['need_update']) or !$user['need_update'])
{
getuserdata($user['id'], true);
}

// +-----------------------------------------------------------------------+
// | Check Access and exit when user status is not ok |
// +-----------------------------------------------------------------------+
Expand Down
10 changes: 8 additions & 2 deletions include/dblayer/functions_mysql.inc.php
Expand Up @@ -416,8 +416,14 @@ function single_update($tablename, $set_fields, $where_fields, $flags=0)
* @param array inserts
* @return void
*/
function mass_inserts($table_name, $dbfields, $datas)
function mass_inserts($table_name, $dbfields, $datas, $options=array())
{
$ignore = '';
if (isset($options['ignore']) and $options['ignore'])
{
$ignore = 'IGNORE';
}

if (count($datas) != 0)
{
$first = true;
Expand All @@ -438,7 +444,7 @@ function mass_inserts($table_name, $dbfields, $datas)
if ($first)
{
$query = '
INSERT INTO '.$table_name.'
INSERT '.$ignore.' INTO '.$table_name.'
('.implode(',', $dbfields).')
VALUES';
$first = false;
Expand Down
10 changes: 8 additions & 2 deletions include/functions_user.inc.php
Expand Up @@ -446,6 +446,9 @@ function getuserdata($user_id, $use_cache)
WHERE user_id = '.$userdata['id'];
pwg_query($query);

// Due to concurrency issues, we ask MySQL to ignore errors on
// insert. This may happen when cache needs refresh and that Piwigo is
// called "very simultaneously".
mass_inserts
(
USER_CACHE_CATEGORIES_TABLE,
Expand All @@ -454,7 +457,8 @@ function getuserdata($user_id, $use_cache)
'user_id', 'cat_id',
'date_last', 'max_date_last', 'nb_images', 'count_images', 'count_categories'
),
$user_cache_cats
$user_cache_cats,
array('ignore' => true)
);


Expand All @@ -464,8 +468,10 @@ function getuserdata($user_id, $use_cache)
WHERE user_id = '.$userdata['id'];
pwg_query($query);

// for the same reason as user_cache_categories, we ignore error on
// this insert
$query = '
INSERT INTO '.USER_CACHE_TABLE.'
INSERT IGNORE INTO '.USER_CACHE_TABLE.'
(user_id, need_update, cache_update_time, forbidden_categories, nb_total_images,
image_access_type, image_access_list)
VALUES
Expand Down

0 comments on commit d827eac

Please sign in to comment.