2

There are many files like this in var/report.

{"0":"Area code is not set","1":"#0 vendor\/magento\/module-customer\/Model\/Plugin\/CustomerNotification.php(78): Magento\\Framework\\App\\State->getAreaCode()\n#1 vendor\/magento\/framework\/Interception\/Interceptor.php(121): Magento\\Customer\\Model\\Plugin\\CustomerNotification->beforeDispatch(Object(Magento\\Checkout\\Controller\\Cart\\Delete\\Interceptor), Object(Magento\\Framework\\App\\Request\\Http))\n#2 vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\\Checkout\\Controller\\Cart\\Delete\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n#3 generated\/code\/Magento\/Checkout\/Controller\/Cart\/Delete\/Interceptor.php(26): Magento\\Checkout\\Controller\\Cart\\Delete\\Interceptor->___callPlugins('dispatch', Array, Array)\n#4 vendor\/magento\/framework\/App\/FrontController.php(55): Magento\\Checkout\\Controller\\Cart\\Delete\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#5 vendor\/magento\/framework\/Interception\/Interceptor.php(58): Magento\\Framework\\App\\FrontController->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#6 vendor\/magento\/framework\/Interception\/Interceptor.php(138): Magento\\Framework\\App\\FrontController\\Interceptor->___callParent('dispatch', Array)\n#7 vendor\/magento\/module-store\/App\/FrontController\/Plugin\/RequestPreprocessor.php(94): Magento\\Framework\\App\\FrontController\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n#8 vendor\/magento\/framework\/Interception\/Interceptor.php(135): Magento\\Store\\App\\FrontController\\Plugin\\RequestPreprocessor->aroundDispatch(Object(Magento\\Framework\\App\\FrontController\\Interceptor), Object(Closure), Object(Magento\\Framework\\App\\Request\\Http))\n#9 vendor\/magento\/module-page-cache\/Model\/App\/FrontController\/BuiltinPlugin.php(73): Magento\\Framework\\App\\FrontController\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n#10 vendor\/magento\/framework\/Interception\/Interceptor.php(135): Magento\\PageCache\\Model\\App\\FrontController\\BuiltinPlugin->aroundDispatch(Object(Magento\\Framework\\App\\FrontController\\Interceptor), Object(Closure), Object(Magento\\Framework\\App\\Request\\Http))\n#11 vendor\/magento\/framework\/Interception\/Interceptor.php(153): Magento\\Framework\\App\\FrontController\\Interceptor->Magento\\Framework\\Interception\\{closure}(Object(Magento\\Framework\\App\\Request\\Http))\n#12 generated\/code\/Magento\/Framework\/App\/FrontController\/Interceptor.php(26): Magento\\Framework\\App\\FrontController\\Interceptor->___callPlugins('dispatch', Array, NULL)\n#13 vendor\/magento\/framework\/App\/Http.php(135): Magento\\Framework\\App\\FrontController\\Interceptor->dispatch(Object(Magento\\Framework\\App\\Request\\Http))\n#14 vendor\/magento\/framework\/App\/Bootstrap.php(256): Magento\\Framework\\App\\Http->launch()\n#15 index.php(39): Magento\\Framework\\App\\Bootstrap->run(Object(Magento\\Framework\\App\\Http\\Interceptor))\n#16 {main}","url":"\/checkout\/cart\/delete\/","script_name":"\/index.php"}
Allen Infante
  • 190
  • 11

1 Answers1

3

I encountered this issue, manifested as a 503 page to the user, and had some trouble tracking down the cause. I created a plugin around the exception to catch it, as was suggested, but all that happened was that the 503 page was now being delivered with a 200 response code!

Eventually, it was discovered that when redis session locking is enabled, and a request is taking too long, redis will timeout and include the 503 page. This new request has no area code set, and causes the exception.

So, ultimately, it is/was a performance issue - one of the requests being generated by the page was holding the redis session lock for too long, and another of the requests was timing out. You can increase the timeout (default 3 seconds) by increasing the max_concurrency setting in redis - the default is 6 (number of 0.5 second sleeps), and after increasing to 12, the problem has not happened again.

Note - the magento documentation : https://devdocs.magento.com/guides/v2.0/config-guide/redis/redis-session.html describes the max_concurrency setting as "Maximum number of processes that can wait for a lock on one session. For large production clusters, set this to at least 10% of the number of PHP processes."

That is not what the setting does (or at least it's not the complete picture) - if you look at vendor/colinmollenhour/php-redis-session-abstract/src/Cm/RedisSession/Handler->read you can see that any one session will try for a lock, and if unsuccessful, increase the wait counter and sleep for half a second before trying again.

Ultimately, the fix for the issue is to improve the performance of the page, but modifying the setting will at least prevent errors in the meantime.