Problem/Motivation

Drupal trigger this error when run drush updb :

Drupal\Core\Entity\EntityStorageException: 'action'    [error]
entity with ID 'comment_delete_action' already exists. in
Drupal\Core\Entity\EntityStorageBase->doPreSave() (line 425 of
/var/www/hmail/src/htdocs/core/lib/Drupal/Core/Entity/EntityStorageBase.php).

I think it happens if you synchronise before you update then you are block.

Steps to reproduce

From #8

  1. Using Composer I successfully updated Drupal Core (from 8.37) and Drush (from 8.x) first.
  2. drush updb
  3. Status page has error "DATABASE UPDATES Out of date'
  4. Execute update script. /update.php/results show the error in the IS.

Proposed resolution

Workaround from #10 and #25

  1. DELETE FROM `config` WHERE name = "system.action.comment_delete_action;"
    DELETE FROM `config` WHERE name = "views.view.comment";
    TRUNCATE TABLE `cache_config`;

    or via drush

    drush sql-query "DELETE FROM config WHERE name ='system.action.comment_delete_action';"
    drush sql-query "DELETE FROM config WHERE name ='views.view.comment';"
    drush sql-query "TRUNCATE TABLE cache_config;"
  2. clear cache
  3. run update.php

Reported to work for #19, #24, #26, #27, #28, #31

Remaining tasks

Determine if this is blocking any site from upgrading.

User interface changes

API changes

Data model changes

Release notes snippet

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Musa.thomas created an issue. See original summary.

cilefen’s picture

@Musa.thomas Would you please add more of the steps to reproduce this?

Musa.thomas’s picture

Musa.thomas’s picture

I just start update Database

Musa.thomas’s picture

Issue summary: View changes
cilefen’s picture

Status: Active » Needs review
xjm’s picture

Issue tags: +8.4.0 update
zenlan’s picture

I too am experiencing this issue.

This site is a dev sandbox, the only installed contrib module is "examples", no contrib theme is installed. PHP Version 7.0.22-0ubuntu0.16.04.1 and MySQL Server version: 5.7.19-0ubuntu0.16.04.1

Using Composer I successfully updated Drupal Core (from 8.37) and Drush (from 8.x) first.

Drush Commandline Tool 9.0.0-beta7
Drupal Version 8.4.0

I then executed the database updates, no errors surfaced but it didn't look complete:

admin@osboxes /var/www/html/drupal8.dev $ drush updb
The following updates are pending:

comment module : 
Enable the comment admin view.

dblog module : 
Replace 'Recent log messages' with a view.

field module : 
Remove the stale 'handler_submit' setting for entity_reference fields.

node module : 
Load all form displays for nodes, add status with these settings, save.

system module : 
Clear caches to ensure Classy's message library is always added.
Force field type plugin definitions to be cleared.   @see https:www.drupal.orgnode2403703

views module : 
Fix table names for revision metadata fields.

 Do you wish to run all pending updates? (yes/no) [yes]:
 > 

 [ok] Post updating comment
 [success] Cache rebuild complete.
 [success] Finished performing updates.

admin@osboxes /var/www/html/drupal8.dev $ drush cr
 [success] Cache rebuild complete.

My /admin/reports/status page reports an error:

Errors found
DATABASE UPDATES Out of date
Some modules have database schema updates to install. You should run the database update script immediately.

When I execute the update script via the browser I can see the exception on the /update.php/results page

The following updates returned messages:
comment module
Update enable_comment_admin_view
Failed: Drupal\Core\Entity\EntityStorageException: 'action' entity with ID 'comment_delete_action' already exists. in Drupal\Core\Entity\EntityStorageBase->doPreSave() (line 425 of /var/www/html/drupal8.dev/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php).

zenlan’s picture

OK so I see that this is likely due to an 8.4 dependency issue that is being discussed in various places.

https://www.drupal.org/node/2898119
https://www.drupal.org/node/2914356

Some have recommended adding platform min version to the composer.json file like this...

config": {
      "sort-packages": true,
      "platform": {"php": "5.6"}
    },

... so I did and tried another composer update...

admin@osboxes /var/www/html/drupal8.dev $ composer update drupal/core --with-dependencies
> DrupalProject\composer\ScriptHandler::checkComposerVersion
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 0 installs, 1 update, 0 removals
  - Updating doctrine/inflector (v1.2.0 => v1.1.0): Downloading (100%)         
Writing lock file

... but can't uninstall the comment module to get past the exception during db update.

From what I'm reading the recommendation is to upgrade to PHP 7.1.

zenlan’s picture

So I got around the db update error with some manual SQL.

DELETE FROM `config` WHERE name = "system.action.comment_delete_action;"
DELETE FROM `config` WHERE name = "views.view.comment";
TRUNCATE TABLE `cache_config`;

Cleared cache and ran update.php again, this time without any problems and the status report shows no errors.

dravenk’s picture

I ran into the problem same with #8

xSDx’s picture

Pushing new patch that includes fix for comment

The last submitted patch, 12: comment-action_exist-2915728-12.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

xSDx’s picture

dravenk’s picture

Status: Needs review » Needs work

The test results failed

dravenk’s picture

.

heddn’s picture

Status: Needs work » Needs review

Do we need to add a test here? It seems obvious to me that we should check if the config already exists before creating it again. I've re-queued tests in hopes the earlier failures were just intermittent testbot issues.

petednz’s picture

Thank you zenlan - i don't know how 'correct' your approach is but it worked for me and got me past repeated problems running drush updb and enabled it to complete. The one tweak was a mis-ordered semi-colon

DELETE FROM `config` WHERE name = "system.action.comment_delete_action";
DELETE FROM `config` WHERE name = "views.view.comment";
TRUNCATE TABLE `cache_config`;
heddn’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: -Needs steps to reproduce

Going to go out on a limb here and say an test isn't needed. And the patch obviously fixes the update path.

larowlan’s picture

Version: 8.4.0 » 8.5.x-dev

8.4.x is into 'criticals only' mode, so this needs to go into 8.5.x

larowlan’s picture

Status: Reviewed & tested by the community » Needs work
Issue tags: +Needs tests

We have an existing upgrade path test for this, lets expand on it for this scenario.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.0-alpha1 will be released the week of January 17, 2018, which means new developments and disruptive changes should now be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

nikunj.patel’s picture

Dear zenlan,

Your approached work after running the SQL query.

But the question is why this error occurring ?

Regards,
Nikunj Patel

ressa’s picture

This is how to run the commands via drush:

drush sql-query "DELETE FROM config WHERE name ='system.action.comment_delete_action';"
drush sql-query "DELETE FROM config WHERE name ='views.view.comment';"
drush sql-query "TRUNCATE TABLE cache_config;"
zterry95’s picture

#25 works for me.

bendev’s picture

#25 is also working for me Thanks

cdmo’s picture

#25 worked for me

myDrupal2014_846824658246’s picture

Running the drush commands #25 and then run the update again worked for me too.

Version: 8.6.x-dev » 8.7.x-dev

Drupal 8.6.0-alpha1 will be released the week of July 16, 2018, which means new developments and disruptive changes should now be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

mlg4035’s picture

Got this same error (PHP 7.2, Drupal 8.6.2) and #10 did the trick for me. Thanks!

AswathyAjish’s picture

Patch in #3 worked for me. Thanks.

Version: 8.7.x-dev » 8.8.x-dev

Drupal 8.7.0-alpha1 will be released the week of March 11, 2019, which means new developments and disruptive changes should now be targeted against the 8.8.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Issue summary: View changes
Status: Needs work » Postponed (maintainer needs more info)

Is anyone experiencing this problem? If so, add a comment.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Postponed (maintainer needs more info) » Closed (outdated)

There have been no reports of this problem for 4 years or that it is blocking an upgrade. For anyone encounetring this the workarounds are listed in the Issue Summary.

Therefore, closing as outdated. If you are encountering this problem open a new issue and refer to this one.

Thanks!