magento2: 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://<yoursite>/graphql on our sites trigger a 500 server error across all cms, category, product, cart pages.

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

  • 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”.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 30 (5 by maintainers)

Most upvoted comments

Problem still exists on 2.4.5-p1

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' => [],
],

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:

Screenshot 2022-10-31 at 10 23 24

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])) {