Changeset 12747


Ignore:
Timestamp:
Dec 16, 2011, 2:52:40 PM (9 years ago)
Author:
plg
Message:

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.

Location:
branches/2.3
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/2.3/admin/batch_manager_global.php

    r12476 r12747  
    4141  $param_name = 'upload_form_'.$param_shortname;
    4242  $form_values[$param_shortname] = $conf[$param_name];
    43 }
    44 
    45 // User cache must not be regenerated during simultaneous ajax requests
    46 if (!isset($user['need_update']) or !$user['need_update'])
    47 {
    48   getuserdata($user['id'], true);
    4943}
    5044
  • branches/2.3/include/dblayer/functions_mysql.inc.php

    r12010 r12747  
    417417 * @return void
    418418 */
    419 function mass_inserts($table_name, $dbfields, $datas)
    420 {
     419function mass_inserts($table_name, $dbfields, $datas, $options=array())
     420{
     421  $ignore = '';
     422  if (isset($options['ignore']) and $options['ignore'])
     423  {
     424    $ignore = 'IGNORE';
     425  }
     426 
    421427  if (count($datas) != 0)
    422428  {
     
    439445      {
    440446        $query = '
    441 INSERT INTO '.$table_name.'
     447INSERT '.$ignore.' INTO '.$table_name.'
    442448  ('.implode(',', $dbfields).')
    443449  VALUES';
  • branches/2.3/include/functions_user.inc.php

    r12339 r12747  
    447447      pwg_query($query);
    448448
     449      // Due to concurrency issues, we ask MySQL to ignore errors on
     450      // insert. This may happen when cache needs refresh and that Piwigo is
     451      // called "very simultaneously".
    449452      mass_inserts
    450453      (
     
    455458          'date_last', 'max_date_last', 'nb_images', 'count_images', 'count_categories'
    456459        ),
    457         $user_cache_cats
     460        $user_cache_cats,
     461        array('ignore' => true)
    458462      );
    459463
     
    465469      pwg_query($query);
    466470
     471      // for the same reason as user_cache_categories, we ignore error on
     472      // this insert
    467473      $query = '
    468 INSERT INTO '.USER_CACHE_TABLE.'
     474INSERT IGNORE INTO '.USER_CACHE_TABLE.'
    469475  (user_id, need_update, cache_update_time, forbidden_categories, nb_total_images,
    470476    image_access_type, image_access_list)
Note: See TracChangeset for help on using the changeset viewer.