Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrity constraint violation SQL Error on saving attributes #6198

Closed
Asitis opened this issue Aug 17, 2016 · 6 comments
Closed

Integrity constraint violation SQL Error on saving attributes #6198

Asitis opened this issue Aug 17, 2016 · 6 comments

Comments

@Asitis
Copy link

Asitis commented Aug 17, 2016

Preconditions

  1. System: Magento 2.1 (installed, not upgraded)
  2. Database: MariaDB10.1
  3. PHP 7.0.7
  4. All caches enabled
  5. 4 storeviews, 2 enabled, 2 disabled

Steps to reproduce

  1. Add product attribute via Admin Stores > Attributes
  2. Fill in data and labels
  3. Click save

Expected result

The attribute saving correctly

Actual result

In a error-message box (page doesn't break):

SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (admin_pubmag.eav_attribute_label, CONSTRAINT EAV_ATTRIBUTE_LABEL_STORE_ID_STORE_STORE_ID FOREIGN KEY (store_id) REFERENCES xstore (store_id) ON DELETE CASCADE), query was: INSERT INTO eav_attribute_label (attribute_id, store_id, value) VALUES (?, ?, ?)

  • The filled labels are empty again, if I leave them empty I can save the attribute.
  • Whenever I save the attribute first, then try to fill in the labels; same error.

I've seen other related issues of non-responsive contributors with this error popping up on other instances ( #5709 #6101 ). I already spoke to my sysadmin if it could be related to SQL versions, but this shouldn't be the case.

@picamator
Copy link

@Asitis thank you for reporting that issue.
But unfortunately we cannot reproduce it.
Could you please elaborate about:

  1. What fields do you fill in product attributes?
  2. What is an order of "disable", "adding" store views, and "adding" product attributes?
    For instance: you create store views first then add some attributes then make store view disable and then started add new attributes and get error.
  3. Does error appear after trying to save attribute with "Default Label" that was already exist?

@Asitis
Copy link
Author

Asitis commented Aug 30, 2016

Me and a colleague have ran into this problem again on two separate occasions, I'll try to be more clear this time:

The first time this error showed it was while saving a product on the English storeview (ID: 2):

QLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`admin_pubmag`.`catalog_product_entity_varchar`, CONSTRAINT `CATALOG_PRODUCT_ENTITY_VARCHAR_STORE_ID_STORE_STORE_ID` FOREIGN KEY (`store_id`) REFERENCES `xstore` (`store_id`) ON DELETE CASCADE), query was: INSERT INTO `catalog_product_entity_varchar` (`entity_id`,`attribute_id`,`value`,`store_id`) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE `entity_id` = VALUES(`entity_id`), `attribute_id` = VALUES(`attribute_id`), `value` = VALUES(`value`), `store_id` = VALUES(`store_id`)

I then found that whenever I edit anything else (like i.e. categories) in that storeview (ID:2) I get errors like "Something went wrong while saving the category". Checking in the logs I see the same Integrity constraint violation again. I'm pretty sure it has something to do with a mismatch of storeID in the database, but I don't know where (or better, how) to look exactly for the issue.

The order went like this:

  • Magento 2.1 installation via composer
  • Created storeviews in admin
  • Disabled two of four storeviews
  • Created attribute set and attributes in admin
  • Deleted two disabled storeviews

I found a lot of similar issues and topics about it, but I never changed anything in the database manually, nor did I import it from another server.

I've tried to reindex, rebuild and redeploy but without success.

The complete exception.log for this error whilst saving a category on storeview ID2:

[2016-08-30 12:28:44] main.CRITICAL: PDOException: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`admin_mag2`.`catalog_category_entity_varchar`, CONSTRAINT `CATALOG_CATEGORY_ENTITY_VARCHAR_STORE_ID_STORE_STORE_ID` FOREIGN KEY (`store_id`) REFERENCES `xstore` (`store_id`) ON DELETE CASCA) in client/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:228
Stack trace:
#0 client/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php(228): PDOStatement->execute(Array)
#1 client/vendor/magento/framework/DB/Statement/Pdo/Mysql.php(95): Zend_Db_Statement_Pdo->_execute(Array)
#2 client/vendor/magento/zendframework1/library/Zend/Db/Statement.php(303): Magento\Framework\DB\Statement\Pdo\Mysql->_execute(Array)
#3 client/vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#4 client/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `ca...', Array)
#5 client/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(452): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `ca...', Array)
#6 client/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(507): Magento\Framework\DB\Adapter\Pdo\Mysql->_query('INSERT INTO `ca...', Array)
#7 client/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(1851): Magento\Framework\DB\Adapter\Pdo\Mysql->query('INSERT INTO `ca...', Array)
#8 client/vendor/magento/module-eav/Model/ResourceModel/AttributePersistor.php(165): Magento\Framework\DB\Adapter\Pdo\Mysql->insertOnDuplicate('catalog_categor...', Array)
#9 client/vendor/magento/module-eav/Model/ResourceModel/AttributePersistor.php(219): Magento\Eav\Model\ResourceModel\AttributePersistor->processInserts('Magento\\Catalog...', Array)
#10 client/vendor/magento/module-eav/Model/ResourceModel/UpdateHandler.php(170): Magento\Eav\Model\ResourceModel\AttributePersistor->flush('Magento\\Catalog...', Array)
#11 client/vendor/magento/framework/EntityManager/Operation/Update/UpdateAttributes.php(59): Magento\Eav\Model\ResourceModel\UpdateHandler->execute('Magento\\Catalog...', Array, Array)
#12 client/vendor/magento/framework/EntityManager/Operation/Update.php(106): Magento\Framework\EntityManager\Operation\Update\UpdateAttributes->execute(Object(Magento\Catalog\Model\Category\Interceptor), Array)
#13 client/vendor/magento/framework/EntityManager/EntityManager.php(87): Magento\Framework\EntityManager\Operation\Update->execute(Object(Magento\Catalog\Model\Category\Interceptor), Array)
#14 client/vendor/magento/module-catalog/Model/ResourceModel/Category.php(1025): Magento\Framework\EntityManager\EntityManager->save(Object(Magento\Catalog\Model\Category\Interceptor))
#15 client/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Catalog\Model\ResourceModel\Category->save(Object(Magento\Catalog\Model\Category\Interceptor))
#16 client/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Catalog\Model\ResourceModel\Category\Interceptor->___callParent('save', Array)
#17 client/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Catalog...', 'save', Object(Magento\Catalog\Model\ResourceModel\Category\Interceptor), Array, 'catalogsearchFu...')
#18 client/vendor/magento/module-catalog-search/Model/Indexer/Fulltext/Plugin/Category.php(43): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Catalog\Model\Category\Interceptor))
#19 client/vendor/magento/module-catalog-search/Model/Indexer/Fulltext/Plugin/Category.php(29): Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Category->addCommitCallback(Object(Magento\Catalog\Model\ResourceModel\Category\Interceptor), Object(Closure), Object(Magento\Catalog\Model\Category\Interceptor))
#20 client/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Category->aroundSave(Object(Magento\Catalog\Model\ResourceModel\Category\Interceptor), Object(Closure), Object(Magento\Catalog\Model\Category\Interceptor))
#21 client/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Catalog...', 'save', Object(Magento\Catalog\Model\ResourceModel\Category\Interceptor), Array, 'clean_cache')
#22 client/vendor/magento/framework/App/Cache/FlushCacheByTags.php(60): Magento\Catalog\Model\ResourceModel\Category\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Catalog\Model\Category\Interceptor))
#23 client/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Framework\App\Cache\FlushCacheByTags->aroundSave(Object(Magento\Catalog\Model\ResourceModel\Category\Interceptor), Object(Closure), Object(Magento\Catalog\Model\Category\Interceptor))
#24 client/var/generation/Magento/Catalog/Model/ResourceModel/Category/Interceptor.php(364): Magento\Catalog\Model\ResourceModel\Category\Interceptor->___callPlugins('save', Array, Array)
#25 client/vendor/magento/framework/Model/AbstractModel.php(631): Magento\Catalog\Model\ResourceModel\Category\Interceptor->save(Object(Magento\Catalog\Model\Category\Interceptor))
#26 client/vendor/magento/framework/Interception/Interceptor.php(146): Magento\Framework\Model\AbstractModel->save()
#27 client/var/generation/Magento/Catalog/Model/Category/Interceptor.php(1534): Magento\Catalog\Model\Category\Interceptor->___callPlugins('save', Array, Array)
#28 client/vendor/magento/module-catalog/Controller/Adminhtml/Category/Save.php(203): Magento\Catalog\Model\Category\Interceptor->save()
#29 client/var/generation/Magento/Catalog/Controller/Adminhtml/Category/Save/Interceptor.php(24): Magento\Catalog\Controller\Adminhtml\Category\Save->execute()
#30 client/vendor/magento/framework/App/Action/Action.php(102): Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor->execute()
#31 client/vendor/magento/module-backend/App/AbstractAction.php(226): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#32 client/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Backend\App\AbstractAction->dispatch(Object(Magento\Framework\App\Request\Http))
#33 client/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor->___callParent('dispatch', Array)
#34 client/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Catalog...', 'dispatch', Object(Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor), Array, 'adminAuthentica...')
#35 client/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#36 client/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(Object(Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#37 client/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Catalog...', 'dispatch', Object(Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor), Array, 'adminMassaction...')
#38 client/vendor/magento/module-backend/App/Action/Plugin/MassactionKey.php(33): Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#39 client/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Backend\App\Action\Plugin\MassactionKey->aroundDispatch(Object(Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#40 client/var/generation/Magento/Catalog/Controller/Adminhtml/Category/Save/Interceptor.php(65): Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor->___callPlugins('dispatch', Array, Array)
#41 client/vendor/magento/framework/App/FrontController.php(55): Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#42 client/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#43 client/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#44 client/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'install')
#45 client/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#46 client/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#47 client/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#48 client/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#49 client/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#50 client/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#51 {main}

Next Zend_Db_Statement_Exception: SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`admin_mag2`.`catalog_category_entity_varchar`, CONSTRAINT `CATALOG_CATEGORY_ENTITY_VARCHAR_STORE_ID_STORE_STORE_ID` FOREIGN KEY (`store_id`) REFERENCES `xstore` (`store_id`) ON DELETE CASCA), query was: INSERT INTO `catalog_category_entity_varchar` (`entity_id`,`attribute_id`,`value`,`store_id`) VALUES (?, ?, ?, ?) ON DUPLICATE KEY UPDATE `entity_id` = VALUES(`entity_id`), `attribute_id` = VALUES(`attribute_id`), `value` = VALUES(`value`), `store_id` = VALUES(`store_id`) in client/vendor/magento/zendframework1/library/Zend/Db/Statement/Pdo.php:235
Stack trace:
#0 client/vendor/magento/framework/DB/Statement/Pdo/Mysql.php(95): Zend_Db_Statement_Pdo->_execute(Array)
#1 client/vendor/magento/zendframework1/library/Zend/Db/Statement.php(303): Magento\Framework\DB\Statement\Pdo\Mysql->_execute(Array)
#2 client/vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php(480): Zend_Db_Statement->execute(Array)
#3 client/vendor/magento/zendframework1/library/Zend/Db/Adapter/Pdo/Abstract.php(238): Zend_Db_Adapter_Abstract->query('INSERT INTO `ca...', Array)
#4 client/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(452): Zend_Db_Adapter_Pdo_Abstract->query('INSERT INTO `ca...', Array)
#5 client/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(507): Magento\Framework\DB\Adapter\Pdo\Mysql->_query('INSERT INTO `ca...', Array)
#6 client/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(1851): Magento\Framework\DB\Adapter\Pdo\Mysql->query('INSERT INTO `ca...', Array)
#7 client/vendor/magento/module-eav/Model/ResourceModel/AttributePersistor.php(165): Magento\Framework\DB\Adapter\Pdo\Mysql->insertOnDuplicate('catalog_categor...', Array)
#8 client/vendor/magento/module-eav/Model/ResourceModel/AttributePersistor.php(219): Magento\Eav\Model\ResourceModel\AttributePersistor->processInserts('Magento\\Catalog...', Array)
#9 client/vendor/magento/module-eav/Model/ResourceModel/UpdateHandler.php(170): Magento\Eav\Model\ResourceModel\AttributePersistor->flush('Magento\\Catalog...', Array)
#10 client/vendor/magento/framework/EntityManager/Operation/Update/UpdateAttributes.php(59): Magento\Eav\Model\ResourceModel\UpdateHandler->execute('Magento\\Catalog...', Array, Array)
#11 client/vendor/magento/framework/EntityManager/Operation/Update.php(106): Magento\Framework\EntityManager\Operation\Update\UpdateAttributes->execute(Object(Magento\Catalog\Model\Category\Interceptor), Array)
#12 client/vendor/magento/framework/EntityManager/EntityManager.php(87): Magento\Framework\EntityManager\Operation\Update->execute(Object(Magento\Catalog\Model\Category\Interceptor), Array)
#13 client/vendor/magento/module-catalog/Model/ResourceModel/Category.php(1025): Magento\Framework\EntityManager\EntityManager->save(Object(Magento\Catalog\Model\Category\Interceptor))
#14 client/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Catalog\Model\ResourceModel\Category->save(Object(Magento\Catalog\Model\Category\Interceptor))
#15 client/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Catalog\Model\ResourceModel\Category\Interceptor->___callParent('save', Array)
#16 client/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Catalog...', 'save', Object(Magento\Catalog\Model\ResourceModel\Category\Interceptor), Array, 'catalogsearchFu...')
#17 client/vendor/magento/module-catalog-search/Model/Indexer/Fulltext/Plugin/Category.php(43): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Catalog\Model\Category\Interceptor))
#18 client/vendor/magento/module-catalog-search/Model/Indexer/Fulltext/Plugin/Category.php(29): Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Category->addCommitCallback(Object(Magento\Catalog\Model\ResourceModel\Category\Interceptor), Object(Closure), Object(Magento\Catalog\Model\Category\Interceptor))
#19 client/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\CatalogSearch\Model\Indexer\Fulltext\Plugin\Category->aroundSave(Object(Magento\Catalog\Model\ResourceModel\Category\Interceptor), Object(Closure), Object(Magento\Catalog\Model\Category\Interceptor))
#20 client/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Catalog...', 'save', Object(Magento\Catalog\Model\ResourceModel\Category\Interceptor), Array, 'clean_cache')
#21 client/vendor/magento/framework/App/Cache/FlushCacheByTags.php(60): Magento\Catalog\Model\ResourceModel\Category\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Catalog\Model\Category\Interceptor))
#22 client/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Framework\App\Cache\FlushCacheByTags->aroundSave(Object(Magento\Catalog\Model\ResourceModel\Category\Interceptor), Object(Closure), Object(Magento\Catalog\Model\Category\Interceptor))
#23 client/var/generation/Magento/Catalog/Model/ResourceModel/Category/Interceptor.php(364): Magento\Catalog\Model\ResourceModel\Category\Interceptor->___callPlugins('save', Array, Array)
#24 client/vendor/magento/framework/Model/AbstractModel.php(631): Magento\Catalog\Model\ResourceModel\Category\Interceptor->save(Object(Magento\Catalog\Model\Category\Interceptor))
#25 client/vendor/magento/framework/Interception/Interceptor.php(146): Magento\Framework\Model\AbstractModel->save()
#26 client/var/generation/Magento/Catalog/Model/Category/Interceptor.php(1534): Magento\Catalog\Model\Category\Interceptor->___callPlugins('save', Array, Array)
#27 client/vendor/magento/module-catalog/Controller/Adminhtml/Category/Save.php(203): Magento\Catalog\Model\Category\Interceptor->save()
#28 client/var/generation/Magento/Catalog/Controller/Adminhtml/Category/Save/Interceptor.php(24): Magento\Catalog\Controller\Adminhtml\Category\Save->execute()
#29 client/vendor/magento/framework/App/Action/Action.php(102): Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor->execute()
#30 client/vendor/magento/module-backend/App/AbstractAction.php(226): Magento\Framework\App\Action\Action->dispatch(Object(Magento\Framework\App\Request\Http))
#31 client/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Backend\App\AbstractAction->dispatch(Object(Magento\Framework\App\Request\Http))
#32 client/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor->___callParent('dispatch', Array)
#33 client/vendor/magento/framework/Interception/Chain/Chain.php(63): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Catalog...', 'dispatch', Object(Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor), Array, 'adminAuthentica...')
#34 client/vendor/magento/module-backend/App/Action/Plugin/Authentication.php(143): Magento\Framework\Interception\Chain\Chain->Magento\Framework\Interception\Chain\{closure}(Object(Magento\Framework\App\Request\Http))
#35 client/vendor/magento/framework/Interception/Chain/Chain.php(67): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch(Object(Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#36 client/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Catalog...', 'dispatch', Object(Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor), Array, 'adminMassaction...')
#37 client/vendor/magento/module-backend/App/Action/Plugin/MassactionKey.php(33): Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#38 client/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Backend\App\Action\Plugin\MassactionKey->aroundDispatch(Object(Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#39 client/var/generation/Magento/Catalog/Controller/Adminhtml/Category/Save/Interceptor.php(65): Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor->___callPlugins('dispatch', Array, Array)
#40 client/vendor/magento/framework/App/FrontController.php(55): Magento\Catalog\Controller\Adminhtml\Category\Save\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#41 client/vendor/magento/framework/Interception/Interceptor.php(74): Magento\Framework\App\FrontController->dispatch(Object(Magento\Framework\App\Request\Http))
#42 client/vendor/magento/framework/Interception/Chain/Chain.php(70): Magento\Framework\App\FrontController\Interceptor->___callParent('dispatch', Array)
#43 client/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\Interception\Chain\Chain->invokeNext('Magento\\Framewo...', 'dispatch', Object(Magento\Framework\App\FrontController\Interceptor), Array, 'install')
#44 client/vendor/magento/framework/Module/Plugin/DbStatusValidator.php(69): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Request\Http))
#45 client/vendor/magento/framework/Interception/Interceptor.php(142): Magento\Framework\Module\Plugin\DbStatusValidator->aroundDispatch(Object(Magento\Framework\App\FrontController\Interceptor), Object(Closure), Object(Magento\Framework\App\Request\Http))
#46 client/var/generation/Magento/Framework/App/FrontController/Interceptor.php(26): Magento\Framework\App\FrontController\Interceptor->___callPlugins('dispatch', Array, Array)
#47 client/vendor/magento/framework/App/Http.php(135): Magento\Framework\App\FrontController\Interceptor->dispatch(Object(Magento\Framework\App\Request\Http))
#48 client/vendor/magento/framework/App/Bootstrap.php(258): Magento\Framework\App\Http->launch()
#49 client/index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http))
#50 {main} [] []

@picamator
Copy link

@Asitis thank you for your details.
But we still can not see error in our screen.
Could you please fill gaps (marked as [gap to fill]):

  1. Create storeviews in admin
  2. [gap to fill] What configuration that storeviews have, like localization etc.?
  3. [gap to fill] Do you add attributes, attributes set, products after creating storeviews?
  4. [gap to fill] Do you always follow all notification if they are appeared like "To clear cache", "To reindex" etc.?
  5. Disabled two of four storeviews
  6. [gap to fill] What specific configuration disabled storeviews had?
  7. [gap to fill] Do you add attributes, attributes set, products after disabling storeviews?
  8. Created attribute set and attributes in admin
  9. [gap to fill] Could you please specify what king of attributes you have added?
  10. [gap to fill] Do you add newly created attributes to your just created attrubutes set?
  11. [gap to fill] Do you add attributes, attributes set, products right after adding attributes?
    If yes, what kind of attribute set do you use?
  12. Deleted two disabled storeviews
  13. [gap to fill] Does error appeared right after you are trying create new category?
  14. [gap to fill] Does error appeared right after you are trying update existing category?
    If it is, please set steps when that category was added.
  15. [gap to fill] Does error appeared right after you are trying add new product with newly created attribute set and category?

@Asitis
Copy link
Author

Asitis commented Sep 5, 2016

@picamator I found the culprit. For some reason a few database tables were corrupted.
I ended up fixing it like this:

  • Create SQL dump backup of 'corrupted' database data
  • Installing a clean Magento2.1.1 system
  • Copied database structure of clean system to old system
  • Imported old data into new database structure

It turned out there were duplicate entries for tables such as store_id in the same table. I'm still clueless as how this could've happened, but it's fixed for now. :)

@Asitis Asitis closed this as completed Sep 5, 2016
@ghost
Copy link

ghost commented Feb 16, 2017

@Asitis If you fixed it like that then you probably have bad data now. An integrity constraint violation means that indexes are off or data is missing. Most likely caused by a module or a update that turns off constraints then data being added in. The only way to fix it is to find the data thats missing turn off constraints then re-add the data back in. If you did a fresh import it will make new indexes and you could have corrupt data or improperly index data somewhere. This is why I prefer UUID instead.

@ghost ghost unassigned picamator Feb 16, 2017
@ghost
Copy link

ghost commented Feb 22, 2017

For me it was having a record set with a store id that didn't exist anymore in eav_attribute_label table. So I just deleted all the records that had store id 4 and kept the ones that had store id 1. Problem solved :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants