Compile Error: Cannot declare class Drupal__Core__Entity__Sql__SqlContentEntityStorageTrash665ed930f1d2d, because the name is already in use

Created on 4 June 2024, 3 months ago
Updated 7 June 2024, 3 months ago

Problem/Motivation

The following error sometimes occurs when someone visits the website during a deploy of new code, probably during a cache rebuild:

Compile Error: Cannot declare class Drupal__Core__Entity__Sql__SqlContentEntityStorageTrash665ed930f1d2d, because the name is already in use

Steps to reproduce

This one is hard to reproduce consistently, it seems to only happen when someone visits the site at a very specific point during cache rebuilds.

Proposed resolution

None yet.

🐛 Bug report
Status

Active

Version

3.0

Component

Code

Created by

🇧🇪Belgium DieterHolvoet Brussels

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @DieterHolvoet
  • 🇧🇪Belgium DieterHolvoet Brussels

    Maybe it could help to get rid of PhpStorageFactory::get('trash')->deleteAll(); in TrashEntityTypeManager::clearCachedDefinitions()? Is there any reason these files need to be regenerated on every cache rebuild?

  • 🇧🇪Belgium DieterHolvoet Brussels

    You would think that regenerating the class suffix when deleting existing classes would prevent this issue. Maybe this only happens when someone visits the site between PhpStorageFactory::get('trash')->deleteAll(); and \Drupal::state()->delete('trash.class_suffix');? I'll switch these two lines and see if the issue still happens.

  • Pipeline finished with Success
    3 months ago
    Total: 162s
    #190646
  • 🇷🇴Romania amateescu

    FWIW, I added some `sleep()` calls in that code, executed drush cr and drush updb -y from the CLI, then browsed the site while the commands were still running, and I didn't bump into that error.

    However, if you find that the MR makes a difference in your case, I've no problem with merging it :)

  • 🇧🇪Belgium DieterHolvoet Brussels

    No it doesn't, the issue happened again since adding the patch.

  • Pipeline finished with Success
    3 months ago
    Total: 196s
    #193663
Production build 0.71.5 2024