-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[BUG]: Phalcon\Mvc\Model\Query
does not handle internal transaction on PDOException
#16604
Labels
Comments
poz
changed the title
[BUG]:
[BUG]: Jun 4, 2024
Phalcon\Mvc\Model\Query
does not handle internal transaction on PDO exceptionPhalcon\Mvc\Model\Query
does not handle internal transaction on PDOException
Additional findings: This also happen to |
I look into this |
noone-silent
added a commit
to noone-silent/cphalcon
that referenced
this issue
Jun 10, 2024
…ptions are thrown.
noone-silent
added a commit
to noone-silent/cphalcon
that referenced
this issue
Jun 10, 2024
5 tasks
noone-silent
added a commit
to noone-silent/cphalcon
that referenced
this issue
Jun 10, 2024
…xception-rollback-and-re-throw # Conflicts: # composer.json # tests/cli/Cli/Console/HandleCest.php
niden
added a commit
that referenced
this issue
Jun 16, 2024
…llback-and-re-throw [#16604] - fix: correctly handle transaction rollbacks if exceptions are thrown
niden
added
status: medium
Medium
5.0
The issues we want to solve in the 5.0 release
and removed
status: unverified
Unverified
labels
Jun 16, 2024
Resolved in #16610 Thank you to @noone-silent and thank you @poz for reporting |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Describe the bug
When a PDOException is throw by
Phalcon\Mvc\Model\Query::executeUpdate()
, the internal transaction did not rollback correctly and mess up the subsequent queries.To Reproduce
Steps to reproduce the behavior:
$this->modelsManager->executeQuery
to update for each single row.PDOException
by updating a string value that is longer than varchar(10) (mysql strict mode)Result:
Expected behavior
Details
set sql_mode=STRICT_ALL_TABLES;
Additional context
I did some investigation to the source and notice that in
Phalcon\Mvc\Model\Query
, it does not catch any exception.https://github.com/phalcon/cphalcon/blob/master/phalcon/Mvc/Model/Query.zep#L1485-L1515
I'm not familiar with zephir I've assumed that the exception is not handled properly there. It seems to leave the function instantly without calling connection->rollback when exception happens.
However if I manually called
$this->db->rollback()
right after catching the exception, the result is working as intended. I don't think this is a good workaround in case exception is happened elsewhere though.Below are the (simplified) mysql general log, which also confirms my suspicion.
Noticed how after 3rd row update, the was no more COMMIT because pdo adapater handles transaction level internally and it stays on level 2 until the end of script
The text was updated successfully, but these errors were encountered: