You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Issue when re-opening a closed connection within a transaction #1163
Investigating this it seems like there is an incorrect check in the CheckConnectionOpen() method in the NpgsqlConnection.cs class.
There is a local variable (_postponingClose) which is only set to true if attempting to close a connection when in a transaction otherwise it defaults to false.
Now at the end of CheckConnetionOpen() method, there is a check:
This does not seem to make sense, if _postponingClose = true, then this means an actual connection should exist AND be open as this will only be set when attempting to close a connection which in a transaction. It seems incorrect that it should be throwing an error stating that Connection is not open in this instance.
I think the final check should just be (unless I'm missing some point for checking if _postponingClose has been set at this point):
If I make the described change to the CheckConnectionOpen() method in the NpgsqlConnection.cs class then the functionality works as expected rather then throwing an error.
Can this issue be verified and that the proposed fix is correct?
I've verified that this does not work from at least NpgSql v2.2.5 to the current version v3.1.3
@warcha I know that the distributed transaction and the TransactionScope implementation is buggy, I've been wanting to redo it for a long time but other things were always more important. But it's definitely going to happen for 3.2 - unfortunately I'm not going to be able to work on that for the next few months.
I'll try to take a look at your suggested ASAP though.
@warcha, I finally have some time and have been rewriting the support for System.Transactions these past few days. The new implementation properly handles reopening connections (and even recycles them to avoid unnecessary escalation). If you can help test the upcoming 3.2, you should be able to grab recent 3.2 CI nugets from the unstable feed, or you can wait until a beta is released (hopefully not too long from now).
Activity
roji commentedon Jun 16, 2016
@warcha I know that the distributed transaction and the TransactionScope implementation is buggy, I've been wanting to redo it for a long time but other things were always more important. But it's definitely going to happen for 3.2 - unfortunately I'm not going to be able to work on that for the next few months.
I'll try to take a look at your suggested ASAP though.
roji commentedon Dec 11, 2016
@warcha, I finally have some time and have been rewriting the support for System.Transactions these past few days. The new implementation properly handles reopening connections (and even recycles them to avoid unnecessary escalation). If you can help test the upcoming 3.2, you should be able to grab recent 3.2 CI nugets from the unstable feed, or you can wait until a beta is released (hopefully not too long from now).
warcha commentedon Dec 12, 2016
Thanks @roji, I'll have a look at this asap and let you know if I find any issues.