Bug #90069

Get Deadlock Error on delete cache in redirect modul

Added by Marco Schmidt 10 months ago. Updated 7 months ago.

Status:
Closed
Priority:
Should have
Assignee:
-
Category:
Caching
Target version:
-
Start date:
2020-01-08
Due date:
% Done:

100%

TYPO3 Version:
9
PHP Version:
Tags:
Complexity:
Is Regression:
Sprint Focus:

Description

I've got an error from time to time and cannot reproduce this.

Core: Exception handler (WEB): Uncaught TYPO3 Exception: An exception occurred while executing 'DELETE tags2, cache1 FROM cf_cache_pages_tags AS tags1 JOIN cf_cache_pages_tags AS tags2 ON tags1.identifier = tags2.identifier JOIN cf_cache_pages AS cache1 ON tags1.identifier = cache1.identifier WHERE tags1.tag = 'redirects'': Deadlock found when trying to get lock; try restarting transaction | Doctrine\DBAL\Exception\DeadlockException thrown in file /www/htdocs/xxxx/example.de/typo3_src-9.5.13/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php in line 34.

If this is no bug in TYPO3 Core/Redirect Modul, what can I do? Or can I ignore this message?

Associated revisions

Revision 94d6369b (diff)
Added by Susanne Moog 7 months ago

[BUGFIX] Do not flush redirect cache when re-building

Flushing the redirect cache before rebuilding
is not necessary and may result in dead-locks
if multiple processes try to do the same.

As there is only a single entry for redirects
which gets overwritten when the rebuilding is
finished, there is also no need to tag the entry
as the identifier is enough.

Resolves: #90069
Releases: master, 9.5
Change-Id: I2bc7c5ce9d0f4a37a3b1c9f51df34de556b2f35f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63729
Tested-by: TYPO3com <>
Tested-by: Georg Ringer <>
Tested-by: Benni Mack <>
Reviewed-by: Georg Ringer <>
Reviewed-by: Benni Mack <>

Revision 7dffa0ef (diff)
Added by Susanne Moog 7 months ago

[BUGFIX] Do not flush redirect cache when re-building

Flushing the redirect cache before rebuilding
is not necessary and may result in dead-locks
if multiple processes try to do the same.

As there is only a single entry for redirects
which gets overwritten when the rebuilding is
finished, there is also no need to tag the entry
as the identifier is enough.

Resolves: #90069
Releases: master, 9.5
Change-Id: I2bc7c5ce9d0f4a37a3b1c9f51df34de556b2f35f
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/63743
Tested-by: TYPO3com <>
Tested-by: Georg Ringer <>
Tested-by: Benni Mack <>
Reviewed-by: Georg Ringer <>
Reviewed-by: Benni Mack <>

History

#1 Updated by Marco Schmidt 10 months ago

  • Category set to Caching

#2 Updated by Jonas Schwabe 10 months ago

  • Category changed from Caching to Recycler

We have the same thing from time to time as well (currently ignoring this as it happens very infrequently):

2020-01-08 05:09:49 0x7fd1c5543700
*** (1) TRANSACTION:
TRANSACTION 84974964, ACTIVE 0 sec starting index read
mysql tables in use 3, locked 3
LOCK WAIT 5 lock struct(s), heap size 1136, 3 row lock(s)
MySQL thread id 6789539, OS thread handle 140538938734336, query id 850188977 XXX YYY Sending data
DELETE tags2, cache1 FROM cf_cache_pages_tags AS tags1 JOIN cf_cache_pages_tags AS tags2 ON tags1.identifier = tags2.identifier JOIN cf_cache_pages AS cache1 ON tags1.identifier = cache1.identifier WHERE tags1.tag = 'redirects'
*** (1) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 10979 page no 4 n bits 336 index cache_id of table `YYY`.`cf_cache_pages` trx id 84974964 lock_mode X waiting
Record lock, heap no 223 PHYSICAL RECORD: n_fields 3; compact format; info bits 0
 0: len 9; hex 726564697265637473; asc redirects;;
 1: len 4; hex 5e1555f4; asc ^ U ;;
 2: len 4; hex 000014bd; asc     ;;

*** (2) TRANSACTION:
TRANSACTION 84974962, ACTIVE 0 sec starting index read
mysql tables in use 3, locked 3
9 lock struct(s), heap size 1136, 6 row lock(s)
MySQL thread id 6789540, OS thread handle 140538935523072, query id 850188975 XXX YYY Sending data
DELETE tags2, cache1 FROM cf_cache_pages_tags AS tags1 JOIN cf_cache_pages_tags AS tags2 ON tags1.identifier = tags2.identifier JOIN cf_cache_pages AS cache1 ON tags1.identifier = cache1.identifier WHERE tags1.tag = 'redirects'
*** (2) HOLDS THE LOCK(S):
RECORD LOCKS space id 10979 page no 4 n bits 336 index cache_id of table `YYY`.`cf_cache_pages` trx id 84974962 lock_mode X
Record lock, heap no 223 PHYSICAL RECORD: n_fields 3; compact format; info bits 0
 0: len 9; hex 726564697265637473; asc redirects;;
 1: len 4; hex 5e1555f4; asc ^ U ;;
 2: len 4; hex 000014bd; asc     ;;

*** (2) WAITING FOR THIS LOCK TO BE GRANTED:
RECORD LOCKS space id 10982 page no 3 n bits 280 index PRIMARY of table `YYY`.`cf_cache_pages_tags` trx id 84974962 lock_mode X locks rec but not gap waiting
Record lock, heap no 191 PHYSICAL RECORD: n_fields 5; compact format; info bits 0
 0: len 4; hex 000014bd; asc     ;;
 1: len 6; hex 000005107af5; asc     z ;;
 2: len 7; hex ec0000038f0110; asc        ;;
 3: len 9; hex 726564697265637473; asc redirects;;
 4: len 9; hex 726564697265637473; asc redirects;;

*** WE ROLL BACK TRANSACTION (1)

I think this is what is happening:
For some reason the redirects cache tag is being flushed when the redirect information needs to be cached again (e.g. cache has become stale or was deleted).
This flush is actually not necessary because there is always only one entire with this tag (as far as I can tell) which holds all the data necessary for routing redirects.

So when two requests hit the TYPO3 installation and the cache is not valid, both requests first flush the cache. Locking cf_cache_pages and cf_cache_pages_tags.
So simple solution would be to not flush at all but just write to the same key.

#3 Updated by Jonas Schwabe 10 months ago

  • Category changed from Recycler to Caching

#4 Updated by Alexander Grein 8 months ago

Same here, problem still exists in 9.5.14

#5 Updated by Gerrit Code Review 7 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/c/Packages/TYPO3.CMS/+/63729

#6 Updated by Gerrit Code Review 7 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/c/Packages/TYPO3.CMS/+/63729

#7 Updated by Gerrit Code Review 7 months ago

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

#8 Updated by Susanne Moog 7 months ago

  • Status changed from Under Review to Resolved
  • % Done changed from 0 to 100

#9 Updated by Benni Mack 7 months ago

  • Status changed from Resolved to Closed

Also available in: Atom PDF