2

Most of the site works fine after applying this patch. One exception is that when going to admin->system->cache management->refresh cache, I got the following error. It was just an one-time error. I refreshed the cache again and no error shown. I have no idea what this error means. Should I have any concern?

a:5:{i:0;s:745:"Error in file: "/home/frcb/public_html/app/code/core/Mage/Admin/sql/admin_setup/upgrade-1.6.1.1-1.6.1.2.php" - SQLSTATE[42S01]: Base table or view already exists: 1050 Table 'permission_variable' already exists, query was: CREATE TABLE `permission_variable` (
  `variable_id` int UNSIGNED NOT NULL auto_increment COMMENT 'Variable ID' ,
  `variable_name` varchar(255) NOT NULL default '' COMMENT 'Config Path' ,
  `is_allowed` bool NOT NULL default '0' COMMENT 'Mark that config can be processed by filters' ,
  PRIMARY KEY (`variable_id`, `variable_name`),
  UNIQUE `UNQ_PERMISSION_VARIABLE_VARIABLE_NAME` (`variable_name`)
) COMMENT='System variables that can be processed via content filter' ENGINE=INNODB charset=utf8 COLLATE=utf8_general_ci";i:1;s:954:"#0 /home/frcb/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php(644): Mage::exception('Mage_Core', 'Error in file: ...')
#1 /home/frcb/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php(437): Mage_Core_Model_Resource_Setup->_modifyResourceDb('upgrade', '1.6.1.1', '1.6.1.2')
#2 /home/frcb/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php(320): Mage_Core_Model_Resource_Setup->_upgradeResourceDb('1.6.1.1', '1.6.1.2')
#3 /home/frcb/public_html/app/code/core/Mage/Core/Model/Resource/Setup.php(235): Mage_Core_Model_Resource_Setup->applyUpdates()
#4 /home/frcb/public_html/app/code/core/Mage/Core/Model/App.php(417): Mage_Core_Model_Resource_Setup::applyAllUpdates()
#5 /home/frcb/public_html/app/code/core/Mage/Core/Model/App.php(343): Mage_Core_Model_App->_initModules()
#6 /home/frcb/public_html/app/Mage.php(684): Mage_Core_Model_App->run(Array)
#7 /home/frcb/public_html/index.php(87): Mage::run('', 'store')
#8 {main}";s:3:"url";s:23:"/index.php/admin/cache/";s:11:"script_name";s:10:"/index.php";s:4:"skin";s:7:"default";}

3 Answers 3

5

This means patch's 'admin_setup' update script was executed before and somehow it was overwritten at core_resource table, so Magento trying to run it again but getting exception, thrown initially by Mysql as tables that this upgrade script trying to create is already there.

I'd follow below steps to fix it:

  • Check app/code/core/Mage/Admin/sql/admin_setup/upgrade-1.6.1.1-1.6.1.2.php and figure out what are new tables and data being added/updated.
  • Backup your current database to be safe
  • Cross check with database if all table, data already present.
  • If yes, update core_resource table for code : admin_setup, set version and data_version to 1.6.1.2 , clear cache and you are done
  • If database table/data not matching with upgrade script, this means upgrade was not finished properly when last executed, to fix it, Delete table that was created by partial upgrade,e.g for your case permission_variable and clear cache to run upgrade script again.

Hope it helps.

9
  • I checked the new tables. Tables and data are there and correct. version and data_version are already 1.6.1.2. Like I said, the error only showed once. So maybe the script worked fine the second time?
    – Shawn
    Nov 3, 2015 at 20:44
  • Ah! I missed "I refreshed the cache again and no error shown" yeah looks like script worked fine. core_resource entry was cached I guess.
    – anshuman
    Nov 3, 2015 at 20:49
  • What can happen when you apply the patch with Magento cache fully enabled and compiler on. Disable cache and compiler before applying patches, installing modules. Saves a world of hurt. Nov 3, 2015 at 21:17
  • 1
    It's also possible that someone else hit the site at the same time as you. Magento, in its infinite wisdom, will run all applicable upgrade scripts on every request, even if the same scripts are already running in another request.
    – Agop
    Nov 3, 2015 at 21:30
  • 1
    @Agop - running upgrade script on production env without maintenance flag turned on is terrible idea.
    – anshuman
    Nov 3, 2015 at 21:35
3

I ran into a similar issue while patching a Magento 1.7 site in a sandbox environment.

The patch would be applied correctly and everything would work until I cleared the cache. After clearing the cache, Magento would keep trying to run the 1.6.1.2 admin_setup upgrade and clearing the cache again wouldn't fix the problem.

After some investigation, I figured that Magento incremented the admin_setup resource's version in the cache, but not in the actual database.

I ended up fixing it by manually updating the core_resource table.

UPDATE `core_resource` SET `version` = '1.6.1.2', `data_version` = '1.6.1.2' WHERE `code` = 'admin_setup';

1
  • Just a little complement of information. I think the underlying issue is triggered by not disabling the cache before applying the patch. I'm not 100% sure thought. Apr 18, 2016 at 2:37
0

I got the same error after clearing cache. admin_setup versions in table core_resource where ok.

Solution was simply to login to admin again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.