graphql id_salt causing 500 server errors
Preconditions and environment
- Magento version: 2.4.4
- Anything else that would help a developer reproduce the bug: Issue started after upgrade to 2.4.4 from 2.3.x. We've had this on multiple unconnected websites running 2.4.4.
Steps to reproduce
The issue occurs seemingly at random. We've identified however that sending any request to the graphql endpoint e.g. https://
Expected result
Expected Result: Graphql works as expected, web pages don't produce 500 errors.
Actual result
The following various errors are triggered on loading any web pages:
Notice: Undefined index: frontend in /public_html/vendor/magento/ framework/App/Cache/Frontend/Pool.php on line 90
[2022-07-22T08:24:29.404089+00:00] main.ERROR: SQLSTATE[70100]: <<Unknown error>>: 1927 Connection was killed, query was: SELECT queue_message.topic_name, queue_message.body, queue_message_status.id AS relation_id, queue_message_status.queue_id, queue_message_status.message_id, queue_message_status.status, queue_message_status.updated_at, queue_message_status.number_of_trials AS retries, queue.name AS queue_name FROM queue_message
INNER JOIN queue_message_status ON queue_message.id = queue_message_status.message_id
INNER JOIN queue ON queue.id = queue_message_status.queue_id WHERE (queue_message_status.status IN (2, 5)) AND (queue.name = ‘export’) ORDER BY queue_message_status.updated_at ASC, queue_message_status.id ASC
LIMIT 1
GraphQL (2:3) 1: mutation { 2: createCustomer( ^ 3: input: {
Additional information
We identified that our env.php file had been modified, and the following had been added: , ‘cache’ => [ ‘graphql’ => [ ‘id_salt’ => ‘SALTHERE’ ] ]
Removing the section instantly brought the website back online. Visiting the graphql endpoint again reproduced the issue.
There appear to be multiple recent posts on a stackexchange with the same issue: https://magento.stackexchange.com/questions/357938/magento-2-4-4-suddenly-adds-cache-tag-to-env-php/358492#358492
Release note
No response
Triage and priority
- [X] Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- [ ] Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- [ ] Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- [ ] Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- [ ] Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
Hi @dpdesignthatfits. Thank you for your report. To speed up processing of this issue, make sure that you provided the following information:
- Summary of the issue
- Information on your environment
- Steps to reproduce
- Expected and actual results
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.
- Join Magento Community Engineering Slack and ask your questions in #github channel.
:warning: According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.
: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
Hi @engcom-Delta. 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:
-
[ ] 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).
Details
If the issue has a valid description, the labelIssue: Format is validwill be added to the issue automatically. Please, edit issue description if needed, until labelIssue: Format is validappears. -
[ ] 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add
Issue: Clear Descriptionlabel to the issue by yourself. -
[ ] 3. Add
Component: XXXXXlabel(s) to the ticket, indicating the components it may be related to. -
[ ] 4. Verify that the issue is reproducible on
2.4-developbranchDetails
- Add the comment@magento give me 2.4-develop instanceto deploy test instance on Magento infrastructure.
- If the issue is reproducible on2.4-developbranch, please, add the labelReproduced on 2.4.x.
- If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here! -
[ ] 5. Add label
Issue: Confirmedonce verification is complete. -
[ ] 6. Make sure that automatic system confirms that report has been added to the backlog.
Hi @dpdesignthatfits , Thank you for raising an issue , we have tried to reproduce the issue on Magento 2.4 develop instance, Graphql results looks fine. Please find below screenshot for reference. in fact when sending request graphql endpoint, there was no issues found from our end.
Kindly provide clear steps to reproduce the issue When exactly issue can be replicated.
Graphql worked fine in our tests, however it was the frontend that broke. Can you confirm if the env.php file was automatically modified to include the id_salt section after you sent a request to graphql?
How strange, we recently had a problem throwing an error on that same line. For us it turned out that the .htaccess file was missing some lines and the cache was no longer shown in the admin panel. #35812
I see we also had this GraphQL added to our env.php, but now I have our Litespeed cache back up and running it all works, even with the additional entry in env.php.
How strange, we recently had a problem throwing an error on that same line. For us it turned out that the .htaccess file was missing some lines and the cache was no longer shown in the admin panel. #35812
I see we also had this GraphQL added to our env.php, but now I have our Litespeed cache back up and running it all works, even with the additional entry in env.php.
I wonder if the htaccess edit you made simply sidestepped the issue by moving the cache engine over to litespeed? (If you disable litespeed does the error re-appear)
I can revert to the default built in cache from the backend flush the cache and everything works fine, then I removed the htaccess entry and it fell back to default cache with everything still being fine.
What I am now suspecting is when you select the default cache from the backend it initialises the appropriate config, where as when it falls back to the config it is either not initialised or initialised from a previous version. It could of course be a cron job or something else that has an effect on top of what is obvious.
If you select the default cache from the backend can you trigger the fault anymore? Even if you then switch back to your usual cache option.
Hi @dpdesignthatfits , We have verified the env.php file on magento 2.4 develop instance, we did not find out id_salt section. We will verify it on 2.4.4 instance after upgrading from 2.3.X and confirm you .
Thanks
Hi @dpdesignthatfits , We have verified the env.php file on magento 2.4 develop instance, we did not find out id_salt section. We will verify it on 2.4.4 instance after upgrading from 2.3.X and confirm you .
Thanks
Thank you for checking. Interesting that the id_salt section is missing for you. My understanding from looking at the code in Magento\GraphQlCache\Model\CacheId\CacheIdCalculator.php is that the getSalt() method will always set a salt entry if one doesn't already exist.
`$salt = $this->deploymentConfig->get(self::SALT_CONFIG_PATH); if ($salt) { return $salt; }
$salt = $this->random->getRandomString(ConfigOptionsListConstants::STORE_KEY_RANDOM_STRING_SIZE);
$config = new ConfigData(ConfigFilePool::APP_ENV);
$config->set(self::SALT_CONFIG_PATH, $salt);
$this->envWriter->saveConfig([$config->getFileKey() => $config->getData()], false, null, [], true);
return $salt;`
I appear to have some errors relating to when the issue occured in /pub/error_log (I didn't even know that file was there before now)
[02-Aug-2022 09:56:16 UTC] PHP Warning: Undefined array key "frontend" in /vendor/magento/framework/App/Cache/Frontend/Pool.php on line 90
[02-Aug-2022 09:56:16 UTC] PHP Fatal error: Uncaught TypeError: array_replace_recursive(): Argument #2 must be of type array, null given in /vendor/magento/framework/App/Cache/Frontend/Pool.php:90
Stack trace:
#0 /vendor/magento/framework/App/Cache/Frontend/Pool.php(90): array_replace_recursive()
#1 /vendor/magento/framework/App/Cache/Frontend/Pool.php(68): Magento\Framework\App\Cache\Frontend\Pool->_getCacheSettings()
#2 /vendor/magento/framework/App/Cache/Frontend/Pool.php(156): Magento\Framework\App\Cache\Frontend\Pool->_initialize()
#3 /vendor/magento/framework/App/Cache/Type/FrontendPool.php(87): Magento\Framework\App\Cache\Frontend\Pool->get()
#4 /vendor/magento/framework/App/Cache/Type/Config.php(49): Magento\Framework\App\Cache\Type\FrontendPool->get()
#5 /vendor/magento/framework/Cache/Frontend/Decorator/Bare.php(65): Magento\Framework\App\Cache\Type\Config->_getFrontend()
#6 /vendor/magento/framework/App/ObjectManager/ConfigLoader.php(73): Magento\Framework\Cache\Frontend\Decorator\Bare->load()
#7 /vendor/magento/framework/App/ObjectManager/Environment/Developer.php(79): Magento\Framework\App\ObjectManager\ConfigLoader->load()
#8 /vendor/magento/framework/App/ObjectManagerFactory.php(191): Magento\Framework\App\ObjectManager\Environment\Developer->configureObjectManager()
#9 /vendor/magento/framework/App/Bootstrap.php(212): Magento\Framework\App\ObjectManagerFactory->create()
#10 /vendor/magento/framework/App/Bootstrap.php(127): Magento\Framework\App\Bootstrap->__construct()
#11 /pub/index.php(27): Magento\Framework\App\Bootstrap::create()
#12 {main}
thrown in /vendor/magento/framework/App/Cache/Frontend/Pool.php on line 90
I think the fix from @Hexmage in #35812 would sort the issue.
I did what' s mentioned in #35812 (so change line 89 in Pool.php) but that did not work.
I got
syntax error, unexpected '{'#0 /home/user222/domains/xxxxxx.xx/public_html/vendor/composer/ClassLoader.php(428): Composer\Autoload\includeFile('/home/u58658p55...') #1 [internal function]: Composer\Autoload\ClassLoader->loadClass('Magento\Framewo...') #2 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/ObjectManager/Factory/AbstractFactory.php(121): spl_autoload_call('Magento\Framewo...') #3 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(108): Magento\Framework\ObjectManager\Factory\AbstractFactory->createObject('Magento\Framewo...', Array) #4 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(150): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Framewo...') #5 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(79): Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\Framewo...') #6 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(150): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Framewo...') #7 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(79): Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\Framewo...') #8 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(150): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Framewo...') #9 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/ObjectManager/Factory/Compiled.php(79): Magento\Framework\ObjectManager\Factory\Compiled->get('Magento\Framewo...') #10 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/ObjectManager/ObjectManager.php(70): Magento\Framework\ObjectManager\Factory\Compiled->create('Magento\Framewo...') #11 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/App/ObjectManager/Environment/Compiled.php(113): Magento\Framework\ObjectManager\ObjectManager->get('Magento\Framewo...') #12 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/App/ObjectManagerFactory.php(191): Magento\Framework\App\ObjectManager\Environment\Compiled->configureObjectManager(Object(Magento\Framework\Interception\ObjectManager\Config\Compiled), Array) #13 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/App/Bootstrap.php(212): Magento\Framework\App\ObjectManagerFactory->create(Array) #14 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/App/Bootstrap.php(127): Magento\Framework\App\Bootstrap->__construct(Object(Magento\Framework\App\ObjectManagerFactory), '/home/u58658p55...', Array) #15 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/Console/Cli.php(184): Magento\Framework\App\Bootstrap::create('/home/u58658p55...', Array) #16 /home/user222/domains/xxxxxx.xx/public_html/vendor/magento/framework/Console/Cli.php(84): Magento\Framework\Console\Cli->initObjectManager() #17 /home/user222/domains/xxxxxx.xx/public_html/bin/magento(22): Magento\Framework\Console\Cli->__construct('Magento CLI') #18 {main}
i am Magento 2.4.4!!
@richardreen, I think @Hexmage has a small error from his suggested fix in the other issue thread, he is missing a closing bracket from the if statement:
Fix is changing line 89 from if (null !== $cacheInfo) { to if (null !== $cacheInfo && isset($cacheInfo[FrontendPool::KEY_FRONTEND_CACHE]) {
Try this instead:
if (null !== $cacheInfo && isset($cacheInfo[FrontendPool::KEY_FRONTEND_CACHE])) {
Yes that seems to be a typo on my side sorry about that.
Hi @dpdesignthatfits , We have tried on Magento 2.4.4 instance to reproduce the issue after upgrading, We have found that after running graphql query , "id_salt" attribute is getting added in env.php file . It keeps adding when we run graphql query but we did not find out any error on frontend. it works fine. Hence , please have look at the screenshots and confirm do i need to follow any specific steps to replicate the error.
Frontend:
@engcom-Delta
Those are the only steps we need to follow in order to trigger the issue. It may therefore be a 3rd party extension that's causing the issue to occur. We'll test this on one of our staging websites.
After correcting the files used by module-graphql ( see https://github.com/magento/magento2/issues/35412) the errors are gone and all is working well. Can execute graphql queries and get result and the fronted is working well. And in env.php the mentioned salt… is present and no issues.
@richardreen Is is this commit that fixed it for you?
https://github.com/magento/magento2/commit/562865aa95ca5916f3418da7d430a1c8018b5918#diff-47df49336d51af1eb4a02ab0c1b098aaab7d5ffc57b1f9d4a66446c2e414ce42R208
Yes that is the correct files …
@richardreen It looks like 2.4.5 has been released a few hours back so hopefully an update to that will fix this then.
I doubt that, just been looking at some code at GitHub with tag 2.4.5 and then these files are not corrected…so I suspect this error is back again if installed 2.4.5
Hi @dpdesignthatfits , Thanks for your inputs. Could you please share the update on # https://github.com/magento/magento2/issues/35861#issuecomment-1209426041
Regards,
We have noticed that this issue has not been updated for a period of more than 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.
This just brought down our clients website for a night, so this feels very real right now.
Our env.php looks somewhat like this https://gist.github.com/joshdavenport/8dcea4f378ebe6c6210602d2bc4be66c
It seems likely that this StackOverflow answerer hit the issue on the nose https://magento.stackexchange.com/a/359663/579. We also didn't have any entry in the ['cache'] key of env prior to it getting automatically added for the GraphQL salt.
Is not having values for ['cache']['frontend'] "wrong"?
Or is it a bug that Magento falls over when ['cache'] does exist but ['cache']['frontend'] doesn't? Env.php docs certainly doesn't list that key as required and cache docs support that:
For a, kind of, fix for anybody else experiencing this, we had success with adding an empty value into env so that when/if the GraphQL modules decide to add the cache entry to env, things don't fall over. So our env now looks like this:
'cache' => [
'frontend' => [],
],
For a, kind of, fix for anybody else experiencing this, we had success with adding an empty values into env so that when/if the GraphQL modules decide to add the entry to env, things don't fall over. So our env now looks has this:
'cache' => [ 'frontend' => [], ],
We applied this too after our website went down suddenly. Took an hour to find out where it was coming from.
I am also just now getting this error on a website that has run smoothly ever since we installed the latest version of Magento some time ago. Seems like two other people also experienced this issue after this ticket has been stale for some month. Is this just a strange coincidence?
The fix posted at https://github.com/magento/magento2/issues/35861#issuecomment-1296894551 also seemed to have fixed the issue for me, thanks!
Problem still exists on 2.4.5-p1
I can confirm it, after installing of 2.4.5-p1 this error was there again. But lucky, the mentioned solution of @Hexmage was the only correction to make and then it works normal again!
@richardreen, I think @Hexmage has a small error from his suggested fix in the other issue thread, he is missing a closing bracket from the if statement:
Fix is changing line 89 from if (null !== $cacheInfo) { to if (null !== $cacheInfo && isset($cacheInfo[FrontendPool::KEY_FRONTEND_CACHE]) {
Try this instead:
if (null !== $cacheInfo && isset($cacheInfo[FrontendPool::KEY_FRONTEND_CACHE])) {
I can confirm that after applying this fix, 'if (null !== $cacheInfo && isset($cacheInfo[FrontendPool::KEY_FRONTEND_CACHE])) {' it's working fine.