migrations
migrations copied to clipboard
Error with transaction nesting and rollback and problems with error handling when running a migration
Bug Report
Q | A |
---|---|
BC Break | no |
Version | 3.8.1 |
Summary
In ExceptionConverter.php line 118:
[Doctrine\DBAL\Exception\DriverException (1305)]
An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1305 SAVEPOINT DOCTRINE_2 does not exist
Exception trace:
at /var/www/content/adex-sales/vendor/doctrine/dbal/src/Driver/API/MySQL/ExceptionConverter.php:118
Doctrine\DBAL\Driver\API\MySQL\ExceptionConverter->convert() at /var/www/content/adex-sales/vendor/doctrine/dbal/src/Connection.php:1939
Doctrine\DBAL\Connection->handleDriverException() at /var/www/content/adex-sales/vendor/doctrine/dbal/src/Connection.php:1881
Doctrine\DBAL\Connection->convertExceptionDuringQuery() at /var/www/content/adex-sales/vendor/doctrine/dbal/src/Connection.php:1213
Doctrine\DBAL\Connection->executeStatement() at /var/www/content/adex-sales/vendor/doctrine/dbal/src/Connection.php:1634
Doctrine\DBAL\Connection->rollbackSavepoint() at /var/www/content/adex-sales/vendor/doctrine/dbal/src/Connection.php:1531
Doctrine\DBAL\Connection->rollBack() at /var/www/content/adex-sales/vendor/doctrine/migrations/src/Tools/TransactionHelper.php:56
Doctrine\Migrations\Tools\TransactionHelper::rollbackIfInTransaction() at /var/www/content/adex-sales/vendor/doctrine/migrations/src/DbalMigrator.php:59
Doctrine\Migrations\DbalMigrator->executeMigrations() at /var/www/content/adex-sales/vendor/doctrine/migrations/src/DbalMigrator.php:134
Doctrine\Migrations\DbalMigrator->migrate() at /var/www/content/adex-sales/vendor/doctrine/migrations/src/Tools/Console/Command/MigrateCommand.php:225
Doctrine\Migrations\Tools\Console\Command\MigrateCommand->execute() at /var/www/content/adex-sales/vendor/symfony/console/Command/Command.php:298
Symfony\Component\Console\Command\Command->run() at /var/www/content/adex-sales/vendor/symfony/console/Application.php:1040
Symfony\Component\Console\Application->doRunCommand() at /var/www/content/adex-sales/vendor/symfony/console/Application.php:301
Symfony\Component\Console\Application->doRun() at /var/www/content/adex-sales/vendor/symfony/console/Application.php:171
Symfony\Component\Console\Application->run() at /var/www/content/adex-sales/vendor/devision/devision-base/src/Infrastructure/Doctrine/ConsoleRunner.php:42
Devision\Base\Infrastructure\Doctrine\ConsoleRunner::run() at /var/www/content/adex-sales/vendor/devision/devision-base/bin/doctrine-console:28
include() at /var/www/content/adex-sales/vendor/bin/doctrine-console:119
Current behavior
The actual exception arises due to an exceedingly long indentifer name. It is raised during the execution of the queued SQL queries and more specifically at:
\Doctrine\Migrations\Version\DbalExecutor::executeResult()
at
$this->connection->executeQuery($query->getStatement(), $query->getParameters(), $query->getTypes());
The exception message is:
An exception occurred while executing a query: SQLSTATE[42000]: Syntax error or access violation: 1059 Identifier name 'idx_un_sales_bm_order_order_compensation_sales_bm_order_id_sales_bm_order_compensation_id_not_arc...' is too long
The final output of the migration command does not mention the original error. Another exception occurs during the migration transaction rollback routine.
\Doctrine\Migrations\Version\DbalExecutor::migrationEnd()
When rolling back the transaction in
if ($migration->isTransactional()) {
//only rollback transaction if in transactional mode
TransactionHelper::rollbackIfInTransaction($this->connection);
}
the exception dump in the Summary is raised.
How to reproduce
Have transaction nesting with checkpoints enabled. Create a migration that has an exceedingly long identifier name.
Expected behavior
The expected behavior is for migration transaction rollback to not produce errors and even if it does it is probably a good idea to have an idea of the original exception, which has triggered the transaction rollback to be output by the logger before dumping the final error.