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

ries van Twisk typo3 at rvt.dds.nl
Thu Feb 21 14:32:59 CET 2008


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've added a new patch to bug [3] with this new solution. I don't like
> so much this solution because the error is happening anyway. However  
> I'd
> like a solution that doesn't depend on database.
>
> What do you think about this concurrence problem?
> What solution do you prefer?
> Any other idea?
>
> Best regards,
>   Rego










More information about the TYPO3-dev mailing list