Problem/Motivation
When using Pathauto patterns on entities that have parent/child relationships, swapping the relationship in one action causes an infinite loop. This is with the default out-of-the-box settings for Drupal core and Pathauto, on a minimal site with no nodes and only two terms.
I looked at other issues involving Pathauto and memory usage, but did not find anything open that matches this scenario.
Steps to reproduce
- Install the latest version of Drupal core (currently 11.2.13) with the standard profile, which will create some basic node types and taxonomy vocabularies.
- Using Composer, require Pathauto and its dependencies (CTools and Token). Current versions of these modules are Pathauto 1.15.0, CTools 4.1.0, and Token 1.17.0.
- Enable Pathauto, which will also enable Token.
- Leave all of the core and module settings at their defaults.
- Visit /admin/config/search/path/patterns and add a Pathauto pattern.
- Choose the pattern type Taxonomy term.
- Enter the pattern /[term:vocabulary]/[term:name] and a label.
- Make sure the Enabled box is checked.
- Save the pattern.
- Visit /admin/structure/taxonomy/manage/tags/add and add two taxonomy terms: Term A and Term B. Do not set any hierarchy.
- Note that in the URL Alias vertical tab for each term, the tab description says "Automatic alias."
- On the vocabulary overview page /admin/structure/taxonomy/manage/tags/overview, drag Term B and make it a direct child of Term A.
- Save the vocabulary.
- Note the page responds quickly and shows the updated relationship.
- On the vocabulary overview page, drag to swap the parent/child relationship, so that Term A is a direct child of Term B. This will take more than one drag action. Do not save the vocabulary in between drag actions; wait until the relationship is fully swapped.
- Save the vocabulary.
- Note the browser spins and does not respond.
- Wait for about 5 minutes.
- You may still see the browser spinning, or you may see an error such as: The website encountered an unexpected error. Try again later. Drupal\Core\Entity\EntityStorageException: SQLSTATE[HY000]: General error: 1205 Lock wait timeout exceeded; try restarting transaction: UPDATE "taxonomy_term_data" SET "revision_id"=:db_update_placeholder_0, "vid"=:db_update_placeholder_1, "uuid"=:db_update_placeholder_2, "langcode"=:db_update_placeholder_3 WHERE "tid" = :db_condition_placeholder_0; Array ( [:db_update_placeholder_0] => 1 [:db_update_placeholder_1] => tags [:db_update_placeholder_2] => adf53a52-2a44-4598-981d-1443e0adab4b [:db_update_placeholder_3] => en [:db_condition_placeholder_0] => 1 ) in Drupal\Core\Entity\Sql\SqlContentEntityStorage->save() (line 845 of core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php).
- Navigate away from the vocabulary overview page and then visit it again.
- Note the update you tried to make was not saved.
At various times while testing this on different environments, I've had the whole site crash, and after recovery, the taxonomy overview page doesn't show the two tags involved in the swap. The different effects probably depend on whether the host environment runs out of memory before the database timeout is reached.
This also affects Drupal 10 (same versions of Pathauto and its dependencies).
Proposed resolution
It seems like a bad situation to have this level of problem occur with the default settings and in a scenario that a site editor could easily trigger. Would it be possible to bail out immediately in case of a circular update, and show a form error that recommends doing the swap in more than one step?
Remaining tasks
Determine how to break out of the infinite loop.
User interface changes
None.
API changes
None.
Data model changes
None.
Comments