Project

General

Profile

Actions

Bug #18253

closed

Duplicate entry on cache_pagesection on reloading twice

Added by Ivan Gomez over 16 years ago. Updated about 6 years ago.

Status:
Closed
Priority:
Should have
Category:
Communication
Target version:
-
Start date:
2008-02-19
Due date:
% Done:

0%

Estimated time:
TYPO3 Version:
4.2
PHP Version:
5.1
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

If I reload a page in the frontend twice or two or more persons access the same page at almost the same time, an SQL error in tabe cache_pagesection is show.

That's a concurrence problem incorrectly fixed in http://bugs.typo3.org/view.php?id=4581

That's a concurrence problem is in that piece of code.

Two or more users can do the insert at same time . There aren't transactions or another way to control concurrence and then we can't assume that condition ($GLOBALS['TYPO3_DB']->sql_affected_rows() == 0) is true when a process do the insert because another process could do the insert before.

$GLOBALS['TYPO3_DB']->exec_UPDATEquery('cache_pagesection', 'page_id=' . intval($GLOBALS['TSFE']->id) . ' AND mpvar_hash=' . $mpvar_hash, $dbFields);

if ($GLOBALS['TYPO3_DB']->sql_affected_rows() == 0) {
$dbFields['page_id'] = intval($GLOBALS['TSFE']->id);
$dbFields['mpvar_hash'] = $mpvar_hash;
// HERE ===> two or more execs at the same time
$GLOBALS['TYPO3_DB']->exec_INSERTquery('cache_pagesection', $dbFields);

}

(issue imported from #M7591)


Files

bug_0007591.patch (1.26 KB) bug_0007591.patch Administrator Admin, 2008-02-19 13:34
bug_0007591_without_on_duplicate_key_update.patch (1.21 KB) bug_0007591_without_on_duplicate_key_update.patch Administrator Admin, 2008-02-21 10:56
patch-insert-on-duplicate-key (1.12 KB) patch-insert-on-duplicate-key Administrator Admin, 2008-04-25 17:59

Related issues 5 (0 open5 closed)

Related to TYPO3 Core - Bug #17088: "Duplicate entry" in cache_pagesection when using framesClosedMichael Stucki2007-03-07

Actions
Related to TYPO3 Core - Bug #16751: Duplicate entry on cache_pagesection on reloading twiceClosedMichael Stucki2006-11-29

Actions
Related to TYPO3 Core - Bug #23116: Bug #18253 has not been solved [Duplicate entry on cache_pagesection on reloading twice]Closed2010-07-07

Actions
Has duplicate TYPO3 Core - Bug #18252: Duplicate entry on cache_pagesection on reloading twiceClosedChristian Kuhn2008-02-19

Actions
Is duplicate of TYPO3 Core - Bug #19621: getTreeList causes duplicate entry sql errorClosedRupert Germann2008-11-18

Actions
Actions #1

Updated by Manuel Rego Casasnovas over 16 years ago

Thinking about this very important concurrence problem I've developed a solution that doesn't depend on database.

But in my solution there is the same database error but I hide the error and I do an UPDATE to get the expected result.

I've added a new patch bug_0007591_without_on_duplicate_key_update.patch with this new solution.

Actions #2

Updated by Jo Hasenau over 16 years ago

The same error happens if you reload the page with header(location: blah)
I do this i.e. after saving some incoming data of a form to avoid users resending the very same data by pressing F5.

A quick and dirty workaround was to insert sleep(1) before the header command but I don't think this could be a real solution.

Actions #3

Updated by Michael Stucki over 16 years ago

Which version did you use for reproducing this problem? Notice that in TYPO3 4.2 beta2 it should be solved, otherwise we should fix this asap.

Actions #4

Updated by Alexander Bohndorf over 16 years ago

I think that the patch from Manuel does not really fix the problem but it hides only the resulting error.
I added a patch which uses the INSERT INTO ... ON DUPLICATE KEY UPDATE Statement to combine the insert and update operation as one atomar operation without using transactions.
See the file patch-insert-on-duplicate-key

Actions #5

Updated by Martin Holtz over 15 years ago

this issue is not solved in TYPO3 4.2.6!

there are duplicate entrys:
#19621
#19621

i get this error with
ident = 'TS TEMPLATE'

and it is somehow repoducable: clear cache and then loading many pages at once

Actions #6

Updated by Christian Kuhn over 14 years ago

Duplicate of #19621 which already has a pending patch in core list.

Actions #7

Updated by Benni Mack about 6 years ago

  • Status changed from Resolved to Closed
Actions

Also available in: Atom PDF