Bug #86491

Duplicate entry for PRIMARY key in cache_treelist

Added by R3 H6 12 months ago. Updated 9 months ago.

Status:
Closed
Priority:
Should have
Category:
Caching
Start date:
2018-10-01
Due date:
% Done:

0%

TYPO3 Version:
8
PHP Version:
7.2
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

Occasionally running into this error on an installation with indexed_search. After reloading the page, the error disappeared. The error code in the frontend was shown instead of the indexed_search plugin.

Mon, 01 Oct 2018 09:37:38 +0200 [ALERT] request="0f377e1561597" component="TYPO3.CMS.Frontend.ContentObject.Exception.ProductionExceptionHandler": Oops, an error occurred! Code: 20181001093733ffa01a02 - {"exception":"Doctrine\\DBAL\\Driver\\Mysqli\\MysqliException: Duplicate entry 'aa45edde44b23b3e236fb700c43dab76' for key 'PRIMARY' in \/home\/public_html\/_sources\/typo3_src-8.7.19\/vendor\/doctrine\/dbal\/lib\/Doctrine\/DBAL\/Driver\/Mysqli\/MysqliStatement.php:165

Stack trace:
#0 \/home\/public_html\/_sources\/typo3_src-8.7.19\/vendor\/doctrine\/dbal\/lib\/Doctrine\/DBAL\/Connection.php(1008): Doctrine\\DBAL\\Driver\\Mysqli\\MysqliStatement->execute(Array)

#1 \/home\/public_html\/_sources\/typo3_src-8.7.19\/vendor\/doctrine\/dbal\/lib\/Doctrine\/DBAL\/Connection.php(714): Doctrine\\DBAL\\Connection->executeUpdate('INSERT INTO `ca...', Array, Array)

#2 \/home\/public_html\/_sources\/typo3_src-8.7.19\/typo3\/sysext\/core\/Classes\/Database\/Connection.php(208): Doctrine\\DBAL\\Connection->insert('`cache_treelist...', Array, Array)

#3 \/home\/public_html\/_sources\/typo3_src-8.7.19\/typo3\/sysext\/frontend\/Classes\/ContentObject\/ContentObjectRenderer.php(6984): TYPO3\\CMS\\Core\\Database\\Connection->insert('cache_treelist', Array)

#4 \/home\/public_html\/_sources\/typo3_src-8.7.19\/typo3\/sysext\/indexed_search\/Classes\/Domain\/Repository\/IndexSearchRepository.php(1064): TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer->getTreeList(10, 9999)

#5 \/home\/public_html\/_sources\/typo3_src-8.7.19\/typo3\/sysext\/indexed_search\/Classes\/Domain\/Repository\/IndexSearchRepository.php(322): TYPO3\\CMS\\IndexedSearch\\Domain\\Repository\\IndexSearchRepository->execFinalQuery('4109082,1060002...', -1)

#6 \/home\/public_html\/_sources\/typo3_src-8.7.19\/typo3\/sysext\/indexed_search\/Classes\/Domain\/Repository\/IndexSearchRepository.php(227): TYPO3\\CMS\\IndexedSearch\\Domain\\Repository\\IndexSearchRepository->getResultRows_SQLpointer(Array, -1)

#7 \/home\/public_html\/_sources\/typo3_src-8.7.19\/typo3\/sysext\/indexed_search\/Classes\/Controller\/SearchController.php(276): TYPO3\\CMS\\IndexedSearch\\Domain\\Repository\\IndexSearchRepository->doSearch(Array, -1)

#8 [internal function]: TYPO3\\CMS\\IndexedSearch\\Controller\\SearchController->searchAction(Array)

...

Next Doctrine\\DBAL\\Exception\\UniqueConstraintViolationException: An exception occurred while executing 'INSERT INTO `cache_treelist` (`md5hash`, `pid`, `treelist`, `tstamp`) VALUES (?, ?, ?, ?)' with params [\"aa45edde44b23b3e236fb700c43dab76\", 10, \"39,38,37,36,35,34,33,32,31,30,13,48,49,50,4159,4160,47,63,134,135,54,56,57,59,61,62,136,137,138,139,141,68,65,64,67,66,4161,96,107,124,108,53,109,110,116,117,123,118,119,120,4164,126,4163,17,125,4162,127,4135,4137,82,83,85,90,88,87,86,89,4153,4168,3962,3961,3960,3959,3958,4147,4148,4149,4140,4141,4144,4143,4142,3969,3966,3965,3964,4138,3978,3977,3976,3975,3974,3990,3989,3982,3981,3997,3995,3994,4003,4002,4001,4004,3999,3991,3979,3970,3963,4139,4145,3956,3955,3954,4167,4029,4028,4027,4026,4025,4024,4023,4022,4021,4020,4019,4018,4017,4016,4015,4014,4013,4012,4011,4033,4032,4036,4038,4042,4041,4044,4046,4045,4043,4040,4039,4037,4035,4049,4051,4056,4055,4054,4053,4052,4050,4048,4061,4060,4059,4069,4068,4067,4066,4065,4064,4063,4072,4071,4070,4062,4058,4078,4077,4076,4075,4083,4082,4081,4080,4087,4086,4096,4095,4094,4093,4092,4091,4090,4089,4088,4085,4104,4103,4102,4101,4100,4099,4098,4109,4108,4107,4111,4114,4113,4116,4125,4124,4123,4122,4121,4120,4119,4118,4117,4115,4112,4110,4106,4105,4097,4084,4079,4074,4073,4057,4047,4034,4030,4010,4009,4008,4007,3953,114,112,115,111,4136,4129,128,129,130,131,132,2373,4134,4170,24,25,26,27,28,74,75,121,93,4128,80,94,95,72,73,81,76,79,92,15,4,18,5,6,7,8,9,20,19,16,21,22,23,42,43,45,46,60,4157,4158,14,29,51,4130,4150,4131,4132,4133,40,41,12,11,10\", 1538379453]:

Duplicate entry 'aa45edde44b23b3e236fb700c43dab76' for key 'PRIMARY' in \/home\/public_html\/_sources\/typo3_src-8.7.19\/vendor\/doctrine\/dbal\/lib\/Doctrine\/DBAL\/Driver\/AbstractMySQLDriver.php:66

Stack trace:\n#0 \/home\/public_html\/_sources\/typo3_src-8.7.19\/vendor\/doctrine\/dbal\/lib\/Doctrine\/DBAL\/DBALException.php(128): Doctrine\\DBAL\\Driver\\AbstractMySQLDriver->convertException('An exception oc...', Object(Doctrine\\DBAL\\Driver\\Mysqli\\MysqliException))

#1 \/home\/public_html\/_sources\/typo3_src-8.7.19\/vendor\/doctrine\/dbal\/lib\/Doctrine\/DBAL\/Connection.php(1015): Doctrine\\DBAL\\DBALException::driverExceptionDuringQuery(Object(Doctrine\\DBAL\\Driver\\Mysqli\\Driver), Object(Doctrine\\DBAL\\Driver\\Mysqli\\MysqliException), 'INSERT INTO `ca...', Array)

#2 \/home\/public_html\/_sources\/typo3_src-8.7.19\/vendor\/doctrine\/dbal\/lib\/Doctrine\/DBAL\/Connection.php(714): Doctrine\\DBAL\\Connection->executeUpdate('INSERT INTO `ca...', Array, Array)

#3 \/home\/public_html\/_sources\/typo3_src-8.7.19\/typo3\/sysext\/core\/Classes\/Database\/Connection.php(208): Doctrine\\DBAL\\Connection->insert('`cache_treelist...', Array, Array)

#4 \/home\/public_html\/_sources\/typo3_src-8.7.19\/typo3\/sysext\/frontend\/Classes\/ContentObject\/ContentObjectRenderer.php(6984): TYPO3\\CMS\\Core\\Database\\Connection->insert('cache_treelist', Array)

#5 \/home\/public_html\/_sources\/typo3_src-8.7.19\/typo3\/sysext\/indexed_search\/Classes\/Domain\/Repository\/IndexSearchRepository.php(1064): TYPO3\\CMS\\Frontend\\ContentObject\\ContentObjectRenderer->getTreeList(10, 9999)

#6 \/home\/public_html\/_sources\/typo3_src-8.7.19\/typo3\/sysext\/indexed_search\/Classes\/Domain\/Repository\/IndexSearchRepository.php(322): TYPO3\\CMS\\IndexedSearch\\Domain\\Repository\\IndexSearchRepository->execFinalQuery('4109082,1060002...', -1)

#7 \/home\/public_html\/_sources\/typo3_src-8.7.19\/typo3\/sysext\/indexed_search\/Classes\/Domain\/Repository\/IndexSearchRepository.php(227): TYPO3\\CMS\\IndexedSearch\\Domain\\Repository\\IndexSearchRepository->getResultRows_SQLpointer(Array, -1)

#8 \/home\/public_html\/_sources\/typo3_src-8.7.19\/typo3\/sysext\/indexed_search\/Classes\/Controller\/SearchController.php(276): TYPO3\\CMS\\IndexedSearch\\Domain\\Repository\\IndexSearchRepository->doSearch(Array, -1)

#9 [internal function]: TYPO3\\CMS\\IndexedSearch\\Controller\\SearchController->searchAction(Array)

...

Related issues

Related to TYPO3 Core - Bug #87139: Regression: getTreeList inserts duplicate keys in cache_treelist Closed 2018-12-12
Duplicates TYPO3 Core - Bug #86028: getTreeList inserts duplicate keys in cache_treelist Closed 2018-08-29

Associated revisions

Revision b63f03d6 (diff)
Added by Alexander Schnitzler 10 months ago

[BUGFIX] Remove expired cache_treelist entries during runtime

When \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::getTreeList
checked for an existing cache_treelist entry, the given md5hash and the
expiry timestamp had been compared. As caches do not expire at all by
default, there a very few cases when an entry is actually expired.

However, if a cache entry has been expired, the cache entry hasn't been
removed and therefore the creation of a new cache entry with the same
md5hash identifier resulted in a duplicate entry exception.

To solve this, the affected, expired entry will be removed during runtime.

Releases: master, 8.7
Resolves: #86028
Resolves: #86491
Change-Id: If1a907607db29f7edd0fa77a8bb47a69bdfc0df9
Reviewed-on: https://review.typo3.org/58951
Tested-by: TYPO3com <>
Reviewed-by: Benni Mack <>
Tested-by: Benni Mack <>
Reviewed-by: Markus Klein <>
Tested-by: Markus Klein <>

Revision 7e83f87f (diff)
Added by Alexander Schnitzler 10 months ago

[BUGFIX] Remove expired cache_treelist entries during runtime

When \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::getTreeList
checked for an existing cache_treelist entry, the given md5hash and the
expiry timestamp had been compared. As caches do not expire at all by
default, there a very few cases when an entry is actually expired.

However, if a cache entry has been expired, the cache entry hasn't been
removed and therefore the creation of a new cache entry with the same
md5hash identifier resulted in a duplicate entry exception.

To solve this, the affected, expired entry will be removed during runtime.

Releases: master, 8.7
Resolves: #86028
Resolves: #86491
Change-Id: If1a907607db29f7edd0fa77a8bb47a69bdfc0df9
Reviewed-on: https://review.typo3.org/59031
Tested-by: TYPO3com <>
Reviewed-by: Markus Klein <>
Tested-by: Markus Klein <>

History

#1 Updated by Stephan GroƟberndt 12 months ago

  • Subject changed from Dublicate entry for PRIMARY key in cache_treelist to Duplicate entry for PRIMARY key in cache_treelist

#2 Updated by Sybille Peters 11 months ago

  • Description updated (diff)

#3 Updated by Sybille Peters 11 months ago

  • Related to Bug #84541: Uncaught TYPO3 Exception in indexed_search: duplicate key (hash) error added

#4 Updated by Alexander Schnitzler 10 months ago

  • Duplicates Bug #86028: getTreeList inserts duplicate keys in cache_treelist added

#5 Updated by Alexander Schnitzler 10 months ago

  • Related to deleted (Bug #84541: Uncaught TYPO3 Exception in indexed_search: duplicate key (hash) error)

#6 Updated by Gerrit Code Review 10 months ago

  • Status changed from New to Under Review

Patch set 1 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/58951

#7 Updated by Alexander Schnitzler 10 months ago

  • Category changed from Indexed Search to Caching
  • Assignee set to Alexander Schnitzler
  • Priority changed from -- undefined -- to Should have
  • Target version set to Candidate for patchlevel

#8 Updated by Gerrit Code Review 10 months ago

Patch set 2 for branch master of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/58951

#9 Updated by Gerrit Code Review 10 months ago

Patch set 1 for branch TYPO3_8-7 of project Packages/TYPO3.CMS has been pushed to the review server.
It is available at https://review.typo3.org/59031

#10 Updated by Anonymous 10 months ago

  • Status changed from Under Review to Resolved

#11 Updated by Gerrit Code Review 10 months ago

  • Status changed from Resolved to Under Review

Patch set 1 for branch TYPO3_8-7 of project Teams/Security/TYPO3v4-Core has been pushed to the review server.
It is available at https://review.typo3.org/59040

#12 Updated by Alexander Schnitzler 9 months ago

  • Related to Bug #87139: Regression: getTreeList inserts duplicate keys in cache_treelist added

#13 Updated by Alexander Schnitzler 9 months ago

  • Status changed from Under Review to Closed

Also available in: Atom PDF