My site is going down once or twice a day when it starts throwing the exception \"Front controller reached 100 router match iterations\". Once this happens access to the adm
UPDATE 2: I have some further changes which should help prevent a different cause of the 100 router match iterations
https://github.com/convenient/magento-ce-ee-config-corruption-bug#update-2-further-improvements
====================================================================
UPDATE: MAGENTO HAVE USED MY ANSWER AS A PATCH
https://github.com/convenient/magento-ce-ee-config-corruption-bug#update-good-news-a-patch-from-magento
====================================================================
I've recently spent quite some time looking into this bug. I've written up my full findings, explanation and replication here.
https://github.com/convenient/magento-ce-ee-config-corruption-bug
However, for the short answer. This appears to be a Magento bug which can be corrected by overriding Mage_Core_Model_Config::init
with the following:
public function init($options=array())
{
$this->setCacheChecksum(null);
$this->_cacheLoadedSections = array();
$this->setOptions($options);
$this->loadBase();
$cacheLoad = $this->loadModulesCache();
if ($cacheLoad) {
return $this;
}
//100 Router Fix Start
$this->_useCache = false;
//100 Router Fix End
$this->loadModules();
$this->loadDb();
$this->saveCache();
return $this;
}
EDIT: Updated to test on vanilla 1.5
I just ran the replication script on a vanilla install of 1.5. Which had all caches except for the CONFIG
cache disabled.
It did not produce the 100 router
error as it does on 1.13, but it did break the website and all the homepage displayed was a white screen.
The cause was that when we were looking for a controller and action we were matched with Mage_Core_IndexController::indexAction
instead of Mage_Cms_IndexController::indexAction
.
class Mage_Core_IndexController extends Mage_Core_Controller_Front_Action {
function indexAction()
{
}
}
Mage_Core_IndexController::indexAction
is an empty function, and explains the white page perfectly.
I can no longer replicate this error when placing _useCache = false
into Mage_Core_Model_Config
.
I believe that maybe your Magento sites unique configuration might cause it to completely fail to match a controller, as opposed to falling back to this Mage_Core_IndexController
action?
This message is caused by bad cached config data. I'm not sure what actually causes the cached config to become corrupted - I would guess it could be a number of things that would vary depending on how Magento is running.
I guess, if you can still get to the Magento backend, you can trying clearing cache under System > Cache Management. If that doesn't help (or if you can't get to the Magento backend, which is likely with this error), then determine how your caching is set up by finding the value of < cache >< backend > in app/etc/local.xml. If you're using files for cache (the default), can you can clear out magento/var/cache with
rm -rf /path/to/magento/var/cache/*
If you're using memcached, find the port under < port > and you can do
telnet memcache_server portnumber
flush_all
Or if you're using redis, you can do
telnet redis_server portnumber
FLUSHALL
If Magento is missing the No-Route CMS Page (url key no-route
) or if the default CMS No Route Page
setting isn't set properly in System=>Configuration=>Web=>Default Pages
, Magento can go into an infinite loop till it hits the 100 iterations limit.
This might not help you, but might help others. I was having the same problem out of the blue.
Removing the cache and locks manually did resolve the issue for me (for now).
The error message is too general to try to solve this problem. I suggest you to hire some freelancer Magento web-developer to look to the source of the problem on your actual site. It cannot be solved theoretically.
As seen from the message, the problem occurs because your routers are making circular references for dispatching requests. One of them matches request, but doesn't dispatch and pushes it to redispatch again. Or no router matches request at all.
You can get more information by going to Magento Core file app/code/core/Mage/Core/Controller/Varien/Front.php, find there lines
while (!$request->isDispatched() && $i++<100) {
foreach ($this->_routers as $router) {
if ($router->match($this->getRequest())) {
break;
}
}
}
and replace them with
Mage::log('----Matching routers------------------------------');
Mage::log('Total ' . count($this->_routers) . ': ' . implode(', ', array_keys($this->_routers)));
while (!$request->isDispatched() && $i++<100) {
Mage::log('- Iteration ' . $i);
$requestData = array(
'path_info' => $request->getPathInfo(),
'module' => $request->getModuleName(),
'action' => $request->getActionName(),
'controller' => $request->getControllerName(),
'controller_module' => $request->getControllerModule(),
'route' => $request->getRouteName()
);
$st = '';
foreach ($requestData as $key => $val) {
$st .= "[{$key}={$val}]";
}
Mage::log('Request: ' . $st);
foreach ($this->_routers as $name => $router) {
if ($router->match($this->getRequest())) {
Mage::log('Matched by "' . $name . '" router, class ' . get_class($router));
break;
}
}
}
After that wait for site to produce the error, open var/log/system.log and see there debugging information about what is going on inside your system. It will help to see much more better, what router breaks the system.
I tried all of the above suggestions, and didnt get anywhere. I then attempted a backup, as I was going to try an upgrade, and I got a permission error reading a file. This was pretty strange, so I changed the permissions, and it instantly started working.
chmod 770 app/code/core/Mage/Cms/controllers/IndexController.php
Hope this helps someone.