Skip to content
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

Merged
merged 5 commits into from
Feb 27, 2020

Conversation

dshuvaev
Copy link
Contributor

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.

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.
@dnfclas
Copy link

dnfclas commented Feb 21, 2020

CLA assistant check
All CLA requirements met.

@ajcvickers
Copy link
Member

@dshuvaev You need to sign the CLA before we can look at this PR.

@dshuvaev
Copy link
Contributor Author

@dshuvaev You need to sign the CLA before we can look at this PR.

I am getting approval to do so.

@dshuvaev
Copy link
Contributor Author

@dshuvaev You need to sign the CLA before we can look at this PR.

@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())
Copy link
Member

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"
@AndriySvyryd AndriySvyryd merged commit daa1ed2 into dotnet:master Feb 27, 2020
@AndriySvyryd
Copy link
Member

@dshuvaev Thanks for your contribution!

{
Dependencies.TransactionLogger.AmbientTransactionWarning(this, DateTimeOffset.UtcNow);
var rootTransaction = _ambientTransactions.Any() && _ambientTransactions.TryPeek(out var transaction) ? transaction : null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could make count check.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants