magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.54k stars 9.32k forks source link

Magento 2.4.5: https://website.com/admin/media_gallery/media/index/key 500 error #36258

Closed pmonosolo closed 1 year ago

pmonosolo commented 2 years ago

Preconditions and environment

Browser console is throwing 500 error on this URL: https://website.com/admin/media_gallery/directories/gettree/key/4d486839c31bcb04b636dd6fefd8187545d560766dfba297b62e42ecfedfa25d/?isAjax=true

And directory tree is not generated on the left side (just empty space).

After the error, Magento destroys the admin session and throws an error into debug.log

`#0 [internal function]: Magento\Framework\App\ErrorHandler->handler(2, 'session_start()...', '/home/user...', 186)

1 /home/serveruser/public_html/vendor/magento/framework/Session/SessionManager.php(186): session_start()

2 /home/serveruser/public_html/generated/code/Magento/Backend/Model/Auth/Session/Interceptor.php(32): Magento\Framework\Session\SessionManager->start()

3 /home/serveruser/public_html/vendor/magento/framework/Session/SessionManager.php(123): Magento\Backend\Model\Auth\Session\Interceptor->start()

4 /home/serveruser/public_html/vendor/magento/module-backend/Model/Auth/Session.php(102): Magento\Framework\Session\SessionManager->__construct(Object(Magento\Framework\App\Request\Http), Object(Magento\Framework\Session\SidResolver\Proxy), Object(Magento\Backend\Model\Session\AdminConfig), Object(Magento\Framework\Session\SaveHandler), Object(Magento\Framework\Session\Validator), Object(Magento\Framework\Session\Storage), Object(Magento\Framework\Stdlib\Cookie\PhpCookieManager\Interceptor), Object(Magento\Framework\Stdlib\Cookie\CookieMetadataFactory), Object(Magento\Framework\App\State\Interceptor))

5 /home/serveruser/public_html/generated/code/Magento/Backend/Model/Auth/Session/Interceptor.php(14): Magento\Backend\Model\Auth\Session->__construct(Object(Magento\Framework\App\Request\Http), Object(Magento\Framework\Session\SidResolver\Proxy), Object(Magento\Backend\Model\Session\AdminConfig), Object(Magento\Framework\Session\SaveHandler), Object(Magento\Framework\Session\Validator), Object(Magento\Framework\Session\Storage), Object(Magento\Framework\Stdlib\Cookie\PhpCookieManager\Interceptor), Object(Magento\Framework\Stdlib\Cookie\CookieMetadataFactory), Object(Magento\Framework\App\State\Interceptor), Object(Magento\Framework\Acl\Builder\Proxy), Object(Magento\Backend\Model\UrlInterface\Proxy), Object(Magento\Backend\App\Config), NULL)

6 /home/serveruser/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(121): Magento\Backend\Model\Auth\Session\Interceptor->__construct(Object(Magento\Framework\App\Request\Http), Object(Magento\Framework\Session\SidResolver\Proxy), Object(Magento\Backend\Model\Session\AdminConfig), Object(Magento\Framework\Session\SaveHandler), Object(Magento\Framework\Session\Validator), Object(Magento\Framework\Session\Storage), Object(Magento\Framework\Stdlib\Cookie\PhpCookieManager\Interceptor), Object(Magento\Framework\Stdlib\Cookie\CookieMetadataFactory), Object(Magento\Framework\App\State\Interceptor), Object(Magento\Framework\Acl\Builder\Proxy), Object(Magento\Backend\Model\UrlInterface\Proxy), Object(Magento\Backend\App\Config), NULL)

7 /home/serveruser/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(108): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\Backend...', Array)

8 /home/serveruser/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(150): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Backend...')

9 /home/serveruser/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(79): Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\Backend...')

10 /home/serveruser/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(150): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Backend...')

11 /home/serveruser/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(79): Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\Backend...')

12 /home/serveruser/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(150): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Backend...')

13 /home/serveruser/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(125): Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\Backend...')

14 /home/serveruser/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(86): Magento\Framework\ObjectManager\Factory\Compiled->parseArray(Array)

15 /home/serveruser/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Compiled->create('RequestValidato...')

16 /home/serveruser/public_html/vendor/magento/framework/App/FrontController.php(109): Magento\Framework\ObjectManager\ObjectManager->get('RequestValidato...')

17 /home/serveruser/public_html/generated/code/Magento/Framework/App/FrontController/Interceptor.php(14): Magento\Framework\App\FrontController->__construct(Object(Magento\Framework\App\RouterList), Object(Magento\Framework\App\Response\Http\Interceptor), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)

18 /home/serveruser/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(121): Magento\Framework\App\FrontController\Interceptor->__construct(Object(Magento\Framework\App\RouterList), Object(Magento\Framework\App\Response\Http\Interceptor), NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)

19 /home/serveruser/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(108): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\Framewo...', Array)

20 /home/serveruser/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Framewo...')

21 /home/serveruser/public_html/vendor/magento/framework/App/Http.php(115): Magento\Framework\ObjectManager\ObjectManager->get('Magento\Framewo...')

22 /home/serveruser/public_html/vendor/magento/framework/App/Bootstrap.php(264): Magento\Framework\App\Http->launch()

23 /home/serveruser/public_html/pub/index.php(30): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))

`

I dont know if it's folder permissions (nothing changed there since the upgrade) or something else. There's no

Steps to reproduce

1) Add Whitelist to config.xml

https://developer.adobe.com/commerce/php/tutorials/backend/modify-image-library-permissions/

  <system>
        <media_storage_configuration>
            <allowed_resources>
                <media_gallery_image_folders>
                    <banners_image_folder>banners</banners_image_folder>
                    <brandlogos_image_folder>brandlogos</brandlogos_image_folder>
                </media_gallery_image_folders>
            </allowed_resources>
        </media_storage_configuration>
    </system>

2) Login to Admin 3) Go to: Content -> Media Gallery

Expected result

Directory list is generated and no error thrown

Actual result

Directory list is not generated, error is thrown and Admin user logged out.

Additional information

Not sure whats going on, both my local machine and DEV Server with same settings do not have this issue.

Although, the directory tree does take at least 5 seconds to show up.

Release note

No response

Triage and priority

m2-assistant[bot] commented 2 years ago

Hi @pmonosolo. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


:clock10: You can find the schedule on the Magento Community Calendar page.

:telephone_receiver: The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

:pencil2: Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

pmonosolo commented 2 years ago

My server admin said there was not enough memory assigned - he added more and now this:

image

Its timing out via Cloudflare (100 second limit?)

pmonosolo commented 2 years ago

Looks like whatever the task that runs when it looks through folders runs for too long and just bricks the Media Gallery.

Is there some list generation happening or does this run every time the Media Gallery is opened?

We have a lot of images in our folders, so I assume its related.

m2-assistant[bot] commented 2 years ago

Hi @engcom-Hotel. Thank you for working on this issue. In order to make sure that issue has enough information and ready for development, please read and check the following instruction: :point_down:

engcom-Hotel commented 2 years ago

Hello @pmonosolo,

Thanks for the report and collaboration!

We have tried to reproduce the issue in the Magento 2.4-develop branch but the issue is not reproducible for us. In order to reproduce the issue we have made a custom module which is attached as follows: Magz.zip

We are not getting any error in the below page:

image

Please let us know if we have missed anything.

Thanks

pmonosolo commented 2 years ago

Hello @pmonosolo,

Thanks for the report and collaboration!

We have tried to reproduce the issue in the Magento 2.4-develop branch but the issue is not reproducible for us. In order to reproduce the issue we have made a custom module which is attached as follows: Magz.zip

We are not getting any error in the below page:

image

Please let us know if we have missed anything.

Thanks

Hello @engcom-Hotel

it looks like its related to this issue from 2.4.1: https://github.com/magento/magento2/issues/30596

Same issue, many images, process overloads PHP RAM limit and stalls.

I have tested switching back to Old Gallery Style and that is working - so at least we have some workaround.

The number of images it stalls on is - 5780. Please try more as I dont know the exact process it's using to go through the images (does it go through /catalog/product folders?)

@engcom-Hotel Can you please test with a large number of images in the /media folder?

pmonosolo commented 2 years ago

I dont know if it will help, the files that were throwing out of memory error were these:

[07-Oct-2022 22:26:54 UTC] PHP Fatal error: Allowed memory size of 792723456 bytes exhausted (tried to allocate 8192 bytes) in /home/userhome/public_html/vendor/magento/framework/Filesystem/Driver/File.php on line 1042

image

[07-Oct-2022 22:26:54 UTC] PHP Fatal error: Allowed memory size of 792723456 bytes exhausted (tried to allocate 692224 bytes) in /home/userhome/public_html/vendor/magento/framework/Session/SessionManager.php on line 133

image

I'm having issues replicating the same issue on my local DEV machine with the same amount of files.

I dont know if it's environment related, missing PHP extensions or something else.

The server was migrated recently to PHP8.1 so I assume maybe there's something missing.

engcom-Hotel commented 2 years ago

Hello @pmonosolo,

Thanks for the reply!

As you said, your production server is just migrated with PHP 8.1. So I suggest you check your memory_limit configuration in the PHP.ini file. Meanwhile, we are trying to reproduce the issue with a large number of files.

Thanks

pmonosolo commented 2 years ago

@engcom-Hotel

Our memory limit is up already to 8GB.

There are similar threads on this topic: https://github.com/magento/magento2/pull/35404

engcom-Hotel commented 2 years ago

Hello @pmonosolo,

We have tried this issue with ~8002 images in a folder but still, we are unable to reproduce the issue. I am attaching the screenshot for reference:

image

For us also the memory_limit is set to 8GB and we are using PHP8.1.

Let us know in case we have missed anything.

Thanks

engcom-Hotel commented 1 year ago

Dear @pmonosolo,

We have noticed that this issue has not been updated for a period of 14 Days. Hence we assume that this issue is fixed now, so we are closing it. Please raise a fresh ticket or reopen this ticket if you need more assistance on this.

Regards

pmonosolo commented 1 year ago

@engcom-Hotel Sorry I ran out of steam - the 2.4.5 upgrade took everything out of me...lol.

I'll need to re-approach this in the new year or if somebody in https://github.com/magento/magento2/issues/30596 will pick this up.