Skip to content

Fix transaction leak #2310

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

Merged
merged 2 commits into from
Apr 30, 2020
Merged

Conversation

fredericDelaporte
Copy link
Member

@fredericDelaporte fredericDelaporte commented Feb 2, 2020

Fixes #2144

Instead of disposing ConnectionManager._transaction in AfterTransaction as proposed in #2144, this obsoletes ConnectionManager.Transaction in favor of a new ConnectionManager.CurrentTransaction property which does not create a transaction when none are already created, but yields null.

So now any existing transaction should be the result of a call to BeginTransaction, and its disposal is always a responsibility of the caller.

@fredericDelaporte fredericDelaporte added this to the 5.3 milestone Feb 2, 2020
@@ -370,6 +370,7 @@ protected virtual void Dispose(bool isDisposing)
// don't dispose of multiple times.
return;
}
_isAlreadyDisposed = true;
Copy link
Member Author

@fredericDelaporte fredericDelaporte Feb 2, 2020

Choose a reason for hiding this comment

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

Change kept from #2144: flagging it at the end of this method instead of as soon as possible causes the method to be vulnerable to an endless loop, in case a Dispose is performed inside AfterTransaction, called later by this method.

This change was required by #2144 since it was calling Dispose in AfterTransaction. This PR here does not do it and so does not actually need that change, but still it is safer to have it.

@fredericDelaporte

This comment has been minimized.

@fredericDelaporte
Copy link
Member Author

Rebased for checking the generator update was not requiring a regen for this PR.

@hazzik hazzik merged commit c60136b into nhibernate:master Apr 30, 2020
@hazzik
Copy link
Member

hazzik commented Apr 30, 2020

I did a merge as 2 commits have better representation of the work done.

@fredericDelaporte fredericDelaporte deleted the AdoTransactionLeak branch May 3, 2020 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AdoTransaction memory leak (5.2.5)
3 participants