mirror of
https://github.com/doctrine/orm.git
synced 2026-03-24 06:52:09 +01:00
DDC-1337: Rollback doesn't work on transactional multi table update with mysql #1678
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @doctrinebot on GitHub (Aug 18, 2011).
Originally assigned to: @beberlei on GitHub.
Jira issue originally created by user gedrox:
When doing transactional multi table update using DQL query the changes are not rolled back after exception is raised after the update.
throw new Exception();
@doctrinebot commented on GitHub (Aug 18, 2011):
Comment created by gedrox:
I have done temporary workaround just by commenting out the line
165: $conn->executeUpdate($this->_dropTempTableSql);from class Doctrine\ORM\Query\Exec\MultiTableUpdateExecutor.
I guess it is not correct solution for all platforms, is it?
@doctrinebot commented on GitHub (Aug 18, 2011):
Comment created by @beberlei:
This is a problem with MySQL and Inheritance. Not sure how we can fix this.
@doctrinebot commented on GitHub (Aug 19, 2011):
Comment created by gedrox:
Partial workaround is not dropping the temporary tables at all when on MySQL (at least) platform. These tables are session based and will be dropped automatically.
Still it can't be predicted when a temporary table will be needed inside the transaction, so we cannot make sure the CREATE TEMPORARY TABLE won't be called inside transaction after something has been updated already.
I think the best solution would be to raise exception when temporary table must be created or dropped while inside the transaction. Developer should call temporary table creation and removal manually before/after the transactional code part if it might be needed by the Doctrine.
In my opinion this is really important issue because no warning or exception was raised by the code in the case of rollback, still it didn't work as expected.
@doctrinebot commented on GitHub (Aug 19, 2011):
Comment created by gedrox:
Additionally needed to change temporary table name generation function ClassMetadataInfo::getTemporaryIdTableName() by adding incrementing property suffix:
return str*replace('.', '_', $this->table['name'] . '_id_tmp*' . $this->counter<ins></ins>);after removed temporary table drop execution.
@doctrinebot commented on GitHub (Aug 27, 2011):
Comment created by @beberlei:
This seems very tricky:
@doctrinebot commented on GitHub (Sep 4, 2011):
Comment created by @beberlei:
I wouldnt consider the php documentation to be a good source on MySQL.
If you read http://dev.mysql.com/doc/refman/5.1/en/implicit-commit.html
You get:
{quote}
ALTER TABLE, CREATE TABLE, and DROP TABLE do not commit a transaction if the TEMPORARY keyword is used. (This does not apply to other operations on temporary tables such as CREATE INDEX, which do cause a commit.) However, although no implicit commit occurs, neither can the statement be rolled back. Therefore, use of such statements will violate transaction atomicity: For example, if you use CREATE TEMPORARY TABLE and then roll back the transaction, the table remains in existence.
{quote}
@doctrinebot commented on GitHub (Sep 4, 2011):
Comment created by @beberlei:
Verified that transactions do not get committed when you CREATE or DROP temporary tables. That is also with MySQL 5.1.54 / Ubuntu
You seem to have some other kind of error or something?
@doctrinebot commented on GitHub (Sep 4, 2011):
Comment created by gedrox:
I'm almost sure that updated data was committed in my situation, but will check and provide the test case if possible.
@doctrinebot commented on GitHub (Sep 19, 2011):
Comment created by gedrox:
Found the problem!
It's because the Doctrine calls "DROP TABLE" instead of "DROP TEMPORARY TABLE" when getting rid of the temporary tables.
To prove this strange MySQL behaviour, such PHP script can be executed:
The dump should output "false", still the first inserted record is output.
This is actual at least on Mysql 5.1.54-1ubuntu4 and PHP 5.3.6.
The solution is trivial - use "DROP TEMPORARY TABLE" syntax instead.
@doctrinebot commented on GitHub (Sep 25, 2011):
Comment created by @beberlei:
Verified, even on mysql console client.
Thanks for investigating, big thumbs up.
@doctrinebot commented on GitHub (Sep 25, 2011):
Comment created by @beberlei:
Fixed.
@doctrinebot commented on GitHub (Sep 25, 2011):
Issue was closed with resolution "Fixed"