-
Notifications
You must be signed in to change notification settings - Fork 3.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
Nested ambient transaction #20012
Nested ambient transaction #20012
Conversation
Added resource string for further use to indicate that a parent transaction is completed before child one.
Allowed several nested ambient transactions to be processed. Main scenario is when one transaction with TransactionScopeOption.RequiresNew is created inside another one.
Added two unit tests to check nested ambient scenarios - one for normal flow when both transaction are committed, another for a case when child transaction is committed, and parent is not.
…_Ambient_Transaction
@dshuvaev You need to sign the CLA before we can look at this PR. |
I am getting approval to do so. |
@ajcvickers It is signed. Thank you |
@@ -548,11 +553,16 @@ private void ClearTransactions(bool clearAmbient) | |||
{ | |||
CurrentTransaction = null; | |||
EnlistedTransaction = null; | |||
if (clearAmbient | |||
&& _ambientTransaction != null) | |||
if (clearAmbient && _ambientTransactions.Any()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_ambientTransactions.Count > 0
"Count" in this case works better than "Any"
@dshuvaev Thanks for your contribution! |
{ | ||
Dependencies.TransactionLogger.AmbientTransactionWarning(this, DateTimeOffset.UtcNow); | ||
var rootTransaction = _ambientTransactions.Any() && _ambientTransactions.TryPeek(out var transaction) ? transaction : null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could make count check.
Allowed several nested ambient transactions to be processed. Main scenario is when one transaction with TransactionScopeOption.RequiresNew is created inside another one. Thus when child transaction is complete its results are persisted, while parent transaction can be rejected.