Closed (fixed)
Project:
Trash
Version:
3.1.x-dev
Component:
Code
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
4 Jun 2024 at 09:33 UTC
Updated:
5 Jun 2026 at 16:27 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
dieterholvoet commentedMaybe it could help to get rid ofTrashEntityTypeManager::clearCachedDefinitions()? Is there any reason these files need to be regenerated on every cache rebuild? If at some point we update the template that's used to generate these files, we could regenerate existing classes once in an update hook.I see now that the template uses
original_class, which may change at some point.Comment #3
dieterholvoet commentedYou 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.Comment #5
amateescu commentedFWIW, I added some `sleep()` calls in that code, executed
drush cranddrush updb -yfrom 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 :)
Comment #6
dieterholvoet commentedNo it doesn't, the issue happened again since adding the patch.
Comment #7
socialnicheguru commentedComment #8
amateescu commented@socialnicheguru, there's nothing to review here, the patch in #5 is just meant for debugging, and the MR doesn't contain any commits (anymore).
Did you bump into this problem as well?
Comment #9
socialnicheguru commentedSorry I was looking at this link and thought there was something to review: https://git.drupalcode.org/project/trash/-/merge_requests/25/diffs?commi...
Comment #10
amateescu commentedI think that commit only reverts the initial commit from the MR.
I'm going to close this issue. @DieterHolvoet, please feel free to re-open it if you managed to get more info about this.
Comment #12
dieterholvoet commentedFYI this error is still appearing in logs every now and then:
I also saw it happening once myself, when loading a page while config was being imported. I'm going to try to add this to settings.php, hopefully that fixes it:
$settings['php_storage']['trash']['class'] = \Drupal\Component\PhpStorage\FileStorage::class;That should make sure that classes with the same class suffix are always stored in the same file. The MTimeProtectedFileStorage protects against "rogue" upload scripts that take filenames from $_GET, so it shouldn't be necessary in this case.
Comment #13
tylertech-lee-hazlett commenteddrush updbcan cause it too. I'm getting it on ~25 of 100 sites when running that commandComment #14
dieterholvoet commentedComment #15
amateescu commentedComment #17
amateescu commentedStarted a new MR with an approach I wanted to try for a long time. It's quite a big change, but it should be much more reliable than the current way we swap storage handlers.
Comment #18
the_g_bomb commentedI ran into this same issue during a updatedb as well.
It seemed to happen after a module ran a cache-clear or rebuilt the NodeStorage as a part of its update hook
I developed a workaround to add to the deployment steps, which was to run:
I tried to debug locally and struggled, so I asked AI for help, this is how it described the problem:
My issue with testing the solution is that the issue seems intermittent, so I can't determine if I am lucky and the update hasn't broken it, or if the fix suggested is working.
Comment #19
amateescu commentedAfter splitting out #3569052: Move TrashStorageTrait::buildQuery to a hook implementation and #3569155: Refactor TrashStorageTrait::setPersistentCache to handle the protected methods we were overriding from
SqlContentEntityStorage, the refactoring MR is green!Even though I trust the test coverage that we currently have, I'd appreciate any real-world testing for it :)
Comment #21
twodThe comment on
MemoryBackend::reset()says it's only called during tests, but this is false. If you go to/admin/reports/statusit gets called viaEntityDefinitionUpdateManagerwhen it generates its changelist.It just assumes the method is there. :(
(Related issue discussing not using
MemoryBackendas it's designed for tests: #2973286: Clean up MemoryCache and MemoryBackend naming issues.)After fixing that I stumbled upon a more fundamental problem with this approach. A general decorator is neat, but it can't easily implement all the expected interfaces for all storages. Just going to
/node/1/revisionsshowsNodeController::getRevisionIds()expectsNodeStorageInterfacebut got theTrashEntityStorageDecoratorinstead.I'm not sure how we could get around that without generating adapter classes.
Comment #22
amateescu commentedWoah.. it's kinda embarrassing that I missed that aspect :)
Ok, so a general decorator won't work, but friendsofphp/proxy-manager-lts seems to do the job quite well!
Comment #24
terry_kolodiy commentedPatch from MR:
Comment #25
amateescu commented@terry_kolodiy, that patch looks like an old revision of the MR, which had various problems. You should try to use the latest code from both 3.1.x and the MR.
Comment #27
amateescu commentedEven though I liked the "cleanliness" of the proxy manager approach, I equally dislike bringing in a big dependency like that.
So here's a new MR which just refactors the storage class generation to hopefully handle all possible cache clearing problems and edge cases around multiple web heads.
Comment #30
amateescu commentedMerged into 3.1.x!
Comment #33
the_g_bomb commentedJust had another update hook do a cache clear during a deployment and got caught with this.
Does this need to be backported to 3.x? If I update to the latest stable (3.0.27), will this be solved?
For some reason, I am still on 3.0.18. I'll look into why violinist isn't doing its thing.
Comment #34
amateescu commented@the_g_bomb, there were a few other changes related to this refactor that were done outside this issue, and it would be hard to track down each of them.
But you can safely update to
3.1.x-devthough if you're on Drupal 11.3. This work is the only major change between the 3.x and 3.1.x branches at the moment, so that branch is not in an "unstable" state by any means :) It will start getting official releases when #3376216: Translation support gets done.