When i tried to start a DB backup via:

php bin/magento setup:backup --db

I got this error:

Enabling maintenance mode
DB backup is starting...
Warning: Division by zero in /var/www/magento/vendor/magento/module-backup/Model/Db.php on line 156
Disabling maintenance mode
PHP Fatal error:  Uncaught Exception: User Error: Some transactions have not been committed or rolled back in /var/www/magento/vendor/magentframework/DB/Adapter/Pdo/Mysql.php on line 3774 in /var/www/magento/vendor/magento/framework/App/ErrorHandler.php:61
Stack trace:
#0 [internal function]: Magento\Framework\App\ErrorHandler->handler(256, 'Some transactio...', '/var/www/magent...', 3774, Array)
#1 /var/www/magento/vendor/magento/framework/DB/Adapter/Pdo/Mysql.php(3774): trigger_error('Some transactio...', 256)
#2 [internal function]: Magento\Framework\DB\Adapter\Pdo\Mysql->__destruct()
#3 {main}
  thrown in /var/www/magento/vendor/magento/framework/App/ErrorHandler.php on line 61

My Magento version: 2.1.1

It's the same via the web interface.

  • Could you share with us what your PHP version is? That could be helpful – tjons Oct 16 '16 at 21:45
  • PHP 7.0.8-0ubuntu0.16.04.2 (cli) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies with Zend OPcache v7.0.8-0ubuntu0.16.04.2, Copyright (c) 1999-2016, by Zend Technologies – Mirko Hufnagel Oct 18 '16 at 5:21

So just came across this error myself, thought I might mention it for those who may come across this in future (since it does block updates).

Looks like the db dump crashed while trying to add rows for or around "importexport_importdata" table

A quick glance it looks like a small issue with not checking for a non-zero denominator.

The code/file in question is: https://github.com/magento/magento2/blob/2.1/app/code/Magento/Backup/Model/Db.php#L156

I managed to fix the issue by overriding/localing the file and modifying the line

$limit = floor(self::BUFFER_LENGTH / $tableStatus->getAvgRowLength());


$limit = floor(self::BUFFER_LENGTH / max($tableStatus->getAvgRowLength(), 1));

And keeping the rest intact

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.