[10.x] Fixed implementation related to afterCommit on Postgres and MSSQL database drivers - #48662
Merged
Merged
Conversation
SakiTakamachi
marked this pull request as draft
October 7, 2023 04:48
Contributor
Author
|
The test has failed, so I'll draft it for now. |
Contributor
|
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. |
SakiTakamachi
marked this pull request as ready for review
October 7, 2023 08:22
Member
|
We still need regression tests covering the issue posted to confirm that this fix the issue. |
This was referenced Oct 7, 2023
SakiTakamachi
force-pushed
the
fix/gh-48658
branch
2 times, most recently
from
October 7, 2023 17:35
7565005 to
b98cef5
Compare
SakiTakamachi
force-pushed
the
fix/gh-48658
branch
from
October 7, 2023 17:37
b98cef5 to
e131bad
Compare
Contributor
Author
|
@crynobone |
Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
Member
|
@SakiTakamachi Can you merge this PR: SakiTakamachi#2 |
crynobone
marked this pull request as draft
October 9, 2023 07:06
Contributor
Author
|
@crynobone |
crynobone
marked this pull request as ready for review
October 9, 2023 09:03
afterCommit on Postgres and MSSQL database drivers
crynobone
approved these changes
Oct 9, 2023
Member
|
Thanks! |
|
Thank you all! |
Contributor
|
Nice. Thanks, y'all! 👍🏼 |
timacdonald
pushed a commit
to timacdonald/framework
that referenced
this pull request
Oct 24, 2023
…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 <crynobone@gmail.com> * wip Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> --------- Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com> Co-authored-by: 武田 憲太郎 <takeda@youmind.jp> Co-authored-by: Mior Muhammad Zaki <crynobone@gmail.com>
Merged
7 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
afterCommitbefore 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
finallyofManagesTransactions::transactionis 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
callbacksShouldIgnoreas it is no longer used anywhere.How should TransactionsManager behave?
During normal execution,
afterCommitis 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
afterCommitto be called when level drops to 1.notes
I swapped the order of the
ORinafterCommitCallbacksShouldBeExecuted.This should basically all be handled with
$this->transactionsManager?->afterCommitCallbacksShouldBeExecuted($this->transactions), and to make it clear that$this->transactions == 0is a fallback is.Best regards.