-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
[10.x] Fixed implementation related to afterCommit
on Postgres and MSSQL database drivers
#48662
Conversation
The test has failed, so I'll draft it for now. |
The failing test doesn't seem to be related to this pull request. It's like a test with a probability of failure.
When executed in an infinite loop at the beginning of the 10.x branch, there is a very low probability of failure. |
We still need regression tests covering the issue posted to confirm that this fix the issue. |
7565005
to
b98cef5
Compare
b98cef5
to
e131bad
Compare
@crynobone |
Signed-off-by: Mior Muhammad Zaki <[email protected]>
Signed-off-by: Mior Muhammad Zaki <[email protected]>
@SakiTakamachi Can you merge this PR: SakiTakamachi#2 |
@crynobone |
afterCommit
on Postgres and MSSQL database drivers
Thanks! |
Thank you all! |
Nice. Thanks, y'all! 👍🏼 |
…MSSQL database drivers (laravel#48662) * fix expected level in afterCommitCallbacksShouldBeExecuted * remove callbacksShouldIgnore * Fixed transaction level down timing * Fixed transaction level down timing * Add test - after commit is executed on final commit * style fix style fix * [10.x] Test Improvements Signed-off-by: Mior Muhammad Zaki <[email protected]> * wip Signed-off-by: Mior Muhammad Zaki <[email protected]> --------- Signed-off-by: Mior Muhammad Zaki <[email protected]> Co-authored-by: 武田 憲太郎 <[email protected]> Co-authored-by: Mior Muhammad Zaki <[email protected]>
Overview
fixes #48658
Hi
I checked the implementation regarding
afterCommit
, fixed defects, and deleted unused functions.Cause of the problem
The cause was that by calling
afterCommit
before lowering the transaction level, the transaction behaved as if it existed, even though it actually did not.I solved this problem by lowering the transaction level before calling
afterCommit
, and by lowering the level expected byafterCommitCallbacksShouldBeExecuted()
by one step.I also fixed commit() in the same way.
Other problem
The
finally
ofManagesTransactions::transaction
is unnecessary, so it has been removed. Since the transaction level is lowered withhandleCommitTransactionException()
, using finally will lower the transaction level by two levels.Removed unnecessary features
I removed the functionality related to
callbacksShouldIgnore
as it is no longer used anywhere.How should TransactionsManager behave?
During normal execution,
afterCommit
is expected to be executed when the transaction no longer exists. That is, when the transaction level is 0.When testing using
RefreshDatabase
, the transaction level is increased by +1 first, as shown in the following link.framework/src/Illuminate/Foundation/Testing/RefreshDatabase.php
Line 100 in cddb4f3
So in this case, transaction level 1 will be the lowest, and we would expect
afterCommit
to be called when level drops to 1.notes
I swapped the order of the
OR
inafterCommitCallbacksShouldBeExecuted
.This should basically all be handled with
$this->transactionsManager?->afterCommitCallbacksShouldBeExecuted($this->transactions)
, and to make it clear that$this->transactions == 0
is a fallback is.Best regards.