[TYPO3-dev] Duplicate entry on cache_pagesection on reloading twice

Manuel Rego Casasnovas mrego at igalia.com
Thu Feb 21 15:06:53 CET 2008



ries van Twisk escribió:
> On Feb 21, 2008, at 4:59 AM, Manuel Rego Casasnovas wrote:
>
>   
>> Hello,
>>
>> El mié, 20-02-2008 a las 15:31 +0100, Moreno Feltscher escribió:
>>     
>>> Does this works with dbal? "ON DUPLICATE KEY UPDATE" would be a risk
>>> in this case..
>>>       
>> I don't know if it works with dbal. You can use it since MySQL 3.23  
>> [1].
>>
>> On the other hand, at the moment there is an important concurrence
>> problem at line 385 in [2].
>>
>> The problematic lines:
>> 384: $GLOBALS['TYPO3_DB']->exec_UPDATEquery('cache_pagesection',
>> 'page_id=' . intval($GLOBALS['TSFE']->id) . ' AND mpvar_hash=' .
>> $mpvar_hash, $dbFields);
>> 385: if ($GLOBALS['TYPO3_DB']->sql_affected_rows() == 0) {
>> 386:    $dbFields['page_id'] = intval($GLOBALS['TSFE']->id);
>> 387:    $dbFields['mpvar_hash'] = $mpvar_hash;
>> 388:    $GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_pagesection',
>> $dbFields);
>> 389: }
>>
>> The problem happens when two process try to do the UPDATE and its  
>> can't
>> do it. Then both process go into if and try to do two INSERT with the
>> same key.
>>
>> This problem could happen with more than 2 process.
>>
>> There are some possible solutions for these:
>>   * Use ON DUPLICATE KEY UPDATE, I think that this depends on database
>> or no.
>>   * Use transactions, maybe it depends on database.
>>   * Try to do the insert with @ to don't display erros and if there is
>> error do an UPDATE. This could be problems when you call to
>> "sql_affected_rows", I don't know if it returns the number of affected
>> rows for the last query for all database or only for the current
>> connection, I hope that this will be the second, in the first case we
>> can't use this function to check the error.
>>     
> can the brandt new locking class solve these particular problems?
>   

I don't know what is this class.
I don't have any idea about this class, could you give me more
information about this new class?


Best regards,
   Rego

-- 
Manuel Rego Casasnovas
Ingeniero en Informática
mailto:mrego at igalia.com
Tel: +34 986 10 76 10
Fax: +34 981 91 39 49
Igalia - http://www.igalia.com




More information about the TYPO3-dev mailing list