-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Catch exception from Connection::commit() #9264
Conversation
DBAL 3's version of |
It can but those won't be the wrapper-level exceptions being caught in this patch. It could be a driver exception, a PDO exception, or anything else but I don't think that catching I believe that since DBAL 3 doesn't provide an API for handling commit exceptions, the ORM shouldn't be using it. |
I was mainly thinking about |
This is really out of scope. I'm trying to improve the ORM compatibility with DBAL 4, not address the API design issues of the earlier DBAL versions. |
Okay, but right now, the 3.0.x branch is compatible with DBAL 3 and we don't want to change that, do we? You would introduce a piece of logic that would catch exceptions that can be raised by DBAL 3 already. At the moment, the ORM behaves differently for those exceptions than it does for a |
I definitely do not intend to change any existing behavior. What's the case with commit and |
Looking at the code of if ($this->transactionNestingLevel === 0) {
throw ConnectionException::noActiveTransaction();
}
if ($this->isRollbackOnly) {
throw ConnectionException::commitFailedRollbackOnly();
} Not catching that exception feels like the right thing to do. If DBAL 4 raises an exception for cases that resulted in a |
These two exceptions being I'm not really familiar with the logic of |
Is there a way for a client that consumes a DBAL connection to distinguish between logic exceptions and runtime exceptions?
The code that we're about to change seems to assume that if a commit fails, it is because of a deadlock or similar situation. The exceptions raised by DBAL 4 should give us more insights on the reason for the failure. My idea would be to only catch exceptions related to locking and let everything else bubble up. |
Another thing: Later in that method, we have a generic catch block that attempts to clean up after a failed transaction: orm/lib/Doctrine/ORM/UnitOfWork.php Lines 442 to 452 in ad97969
Note that the return value of the |
I believe it's better to wait until we can run the test suite. Otherwise, we're shooting in the dark. The major blocker for running the suite is compile-time errors caused by the hard-coded mocks (#8886 (comment)). |
Connection::commit()
will returnvoid
in DBAL 4. See doctrine/dbal#3480.