File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 1414using System . Threading ;
1515using System . Transactions ;
1616using NHibernate . Cfg ;
17+ using NHibernate . Driver ;
1718using NHibernate . Engine ;
1819using NHibernate . Linq ;
1920using NHibernate . Test . TransactionTest ;
@@ -186,6 +187,12 @@ public async Task CanDeleteItemAsync(bool explicitFlush)
186187 public async Task CanUseSessionWithManyScopesAsync ( bool explicitFlush )
187188 {
188189 IgnoreIfUnsupported ( explicitFlush ) ;
190+ // ODBC with SQL-Server always causes scopes to go distributed, which causes their transaction completion to run
191+ // asynchronously. But ODBC enlistment also check the previous transaction in a way that do not guard against it
192+ // being concurrently disposed of. See https://github.com/nhibernate/nhibernate-core/pull/1505 for more details.
193+ Assume . That ( ! ( Sfi . ConnectionProvider . Driver is OdbcDriver ) ,
194+ "ODBC sometimes fails on second scope by checking the previous transaction status, which may yield an object disposed exception" ) ;
195+
189196 using ( var s = WithOptions ( ) . ConnectionReleaseMode ( ConnectionReleaseMode . OnClose ) . OpenSession ( ) )
190197 {
191198 using ( var tx = new TransactionScope ( TransactionScopeAsyncFlowOption . Enabled ) )
@@ -529,4 +536,4 @@ public class SystemTransactionWithoutAutoJoinTransactionAsync : SystemTransactio
529536 {
530537 protected override bool AutoJoinTransaction => false ;
531538 }
532- }
539+ }
Original file line number Diff line number Diff line change 44using System . Threading ;
55using System . Transactions ;
66using NHibernate . Cfg ;
7+ using NHibernate . Driver ;
78using NHibernate . Engine ;
89using NHibernate . Linq ;
910using NHibernate . Test . TransactionTest ;
@@ -175,6 +176,12 @@ public void CanDeleteItem(bool explicitFlush)
175176 public void CanUseSessionWithManyScopes ( bool explicitFlush )
176177 {
177178 IgnoreIfUnsupported ( explicitFlush ) ;
179+ // ODBC with SQL-Server always causes scopes to go distributed, which causes their transaction completion to run
180+ // asynchronously. But ODBC enlistment also check the previous transaction in a way that do not guard against it
181+ // being concurrently disposed of. See https://github.com/nhibernate/nhibernate-core/pull/1505 for more details.
182+ Assume . That ( ! ( Sfi . ConnectionProvider . Driver is OdbcDriver ) ,
183+ "ODBC sometimes fails on second scope by checking the previous transaction status, which may yield an object disposed exception" ) ;
184+
178185 using ( var s = WithOptions ( ) . ConnectionReleaseMode ( ConnectionReleaseMode . OnClose ) . OpenSession ( ) )
179186 {
180187 using ( var tx = new TransactionScope ( ) )
@@ -539,4 +546,4 @@ public void SessionIsNotEnlisted()
539546 }
540547 }
541548 }
542- }
549+ }
You can’t perform that action at this time.
0 commit comments