I am working on installer and upgrade script of Magento 2 In which my InstallSchema, UpgradeSchema and InstallData scripts are working but UpgradeData.php is not working.

Please check the following code and please help me to trace out the issue.

namespace Foggyline\Office\Setup;

use Magento\Framework\Setup\UpgradeDataInterface;
use Magento\Framework\Setup\ModuleContextInterface;
use Magento\Framework\Setup\ModuleDataSetupInterface;

class UpgradeData implements UpgradeDataInterface
    protected $departmentFactory;
    protected $employeeFactory;

    public function __construct(
        \Foggyline\Office\Model\DepartmentFactory $departmentFactory,
        \Foggyline\Office\Model\EmployeeFactory $employeeFactory
        $this->departmentFactory = $departmentFactory;
        $this->employeeFactory = $employeeFactory;

    public function upgrade(ModuleDataSetupInterface $setup, ModuleContextInterface $context)
        //      Start Of Table Department     //

        $salesDepartment = $this->departmentFactory->create();

        //      End Of Table Department                    //
        //      Start of Employee Entity                   //

        $employee = $this->employeeFactory->create();
        $employee->setNote('Just some notes about John');

        //              End Of Employee Entity             //


Note: From above script I am able to make entries in Department table which is a flat table but unable to make entries for employee entity which is an EAV.

I get this error.

[PDOException] There is no active transaction

PHP Fatal error:  Uncaught exception 'Exception' with message 'User Error: Some transactions have not been committed or rolled back in /vagrant/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php on line 3774' in /vagrant/vendor/magento/framework/App/ErrorHandler.php:61

Though I never figured out a better solution, the error occurs due to a failure to serialize the eav attributes when caching them.

One solution is to change app/etc/env.php under 'cache_types' set 'eav' => 0

| improve this answer | |
  • Thanks for the reply but its not working in my case. – Ashish Madankar M2 Professiona Jul 29 '16 at 10:29
  • My previous response was attributing the wrong change to what fixed the error. I edited it to add what I've figured out after a lot more digging. – Syd Aug 10 '16 at 20:26
  • Thanks Syd it works for me after almost 1 month i got to resolve this issue only because of you . Thanks once again. – Ashish Madankar M2 Professiona Aug 11 '16 at 6:54

I really don't know disadvantages of disabling caching for EAV but this issue resolves by disabling caching for EAV either from admin or as Syd answer i.e. from app/etc/env.php

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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